アプリケーション共通の変数を、Global.asaxで定義
概要
タイトルのまんま
元ネタ
前提条件
手順
Global.asax に以下を追加する。
Public Shared ReadOnly str1 As String = "hoge"
not found (245.jpg)
default.aspx を以下のように変更。
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Response.Write(Global.ASP.global_asax.Str1)
End Sub
End Class
以下、実行結果。
not found (246.jpg)