global.asax

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

ASAX
29
字号
<Script Runat="Server">

Sub Application_BeginRequest
  Dim strUsername
  Dim strCustomPath As String

  If INSTR( Request.Path.ToLower, "custom" ) = 0 Then
    strUsername = Request.Path.ToLower
    strUsername = strUsername.Replace( ".aspx", "" )
    strUsername = strUsername.Remove( _
      0, _
      InstrRev( strUsername, "/" ) )
    If Request.ApplicationPath = "/" Then
    strCustomPath = _
      String.Format( _
        "/custom/default.aspx?username={0}", _
        strUsername )
    Else
    strCustomPath = _
      String.Format( _
        "{0}/custom/default.aspx?username={1}", _
        Request.ApplicationPath, _
        strUsername )
    End If 
    Context.RewritePath( strCustomPath )
  End If
End Sub

</Script>

⌨️ 快捷键说明

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