global.asax

来自「asp.net技术内幕的书配源码」· ASAX 代码 · 共 32 行

ASAX
32
字号
<%@ Import Namespace="StoreComponents" %>
<%@ Import Namespace="System.Data" %>

<Script runat="Server">

Sub Application_BeginRequest( s As Object, e As EventArgs )
  Dim intCategory As Integer = -1
  Dim intProductID As Integer = -1
  Dim objProductInfo As DataRowView

  ' Get current category index
  If Request.QueryString( "cat" ) <> "" Then
    intCategory = Request.QueryString( "cat" )
  End If 

  ' Store Category in Context
  Context.Items( "Category" ) = intCategory  

  ' Get current product ID
  If Request.QueryString( "pid" ) <> "" Then
    intProductID = Request.QueryString( "pid" )
    objProductInfo = CachedData.GetProductRow( intProductID )
    Context.Items( "ProductInfo" ) = objProductInfo
    Context.Items( "ProductName" ) = objProductInfo( "ProductName" )
    Context.Items( "UnitPrice" ) = objProductInfo( "UnitPrice" )
  End If 

  ' Store ProductID in Context
  Context.Items( "ProductID" ) = intProductID  
End Sub

</Script>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?