Url rewriting 只有在配置文件或Page指令中将enableSessionState设置为true时,才能使用会话状态

Url rewriting 只有在配置文件或Page指令中将enableSessionState设置为true时,才能使用会话状态,url-rewriting,web-config,server.transfer,Url Rewriting,Web Config,Server.transfer,我在.net(Azure)应用程序中遇到此错误:- 只有在配置文件或页面指令中将enableSessionState设置为true时,才能使用会话状态 我正在重写URL(为此使用server.transfer) 当我直接访问页面或使用Response.Redirect访问页面时,没有错误 有什么想法吗 我正在使用下面的代码 公共类重写器 实现IHttpModule Public Sub Init(ByVal inst As System.Web.HttpApplication)实现System.

我在.net(Azure)应用程序中遇到此错误:- 只有在配置文件或页面指令中将enableSessionState设置为true时,才能使用会话状态

我正在重写URL(为此使用server.transfer)

当我直接访问页面或使用Response.Redirect访问页面时,没有错误

有什么想法吗

我正在使用下面的代码

公共类重写器 实现IHttpModule Public Sub Init(ByVal inst As System.Web.HttpApplication)实现System.Web.IHttpModule.Init AddHandler inst.BeginRequest,地址为Me.OnBeginRequest 端接头

Public Sub OnBeginRequest(ByVal app As Object, ByVal e As EventArgs)
    Dim inst As HttpApplication = CType(app, HttpApplication)
    Dim req_path As String = inst.Context.Request.Path
    Dim trans_path As String = ""
    Select Case req_path.ToLower()
        Case "/firstpage"
            trans_path = "/Default.aspx"
        Case "/secondpage"
            trans_path = "/About.aspx"
        Case "/testapp"
            trans_path = "/Test/Test1.aspx"
        Case Else
            trans_path = "/"
    End Select

    If Not trans_path = "/" Then
        inst.Context.Server.Transfer(trans_path)
    End If
End Sub
末级

在web.config中,我还在httpModules下添加了这个标记:-

   <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
  <add name="URLRewriter" type="URLRewriter"/>
  <add type="System.Web.SessionState.SessionStateModule" name="Session" />

after adding above code in my azure application url rewrite is working fine, but when I try to use session its giving me error(Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive.) means its lossing the session during url rewrite.

在我的azure应用程序中添加上述代码后,url重写工作正常,但当我尝试使用会话时,它的“给我”错误(只有在配置文件或页面指令中将enableSessionState设置为true时,才能使用会话状态)意味着它在url重写期间丢失会话。

您能否提供一些关于您在何处/如何提供服务的代码示例。transfer rewrite?嗨,taylor,我添加了有问题的代码。请检查一下。如果可能的话,请分享一个url重写的例子,它与会话一起工作,因为我的代码丢失了会话。