1

.net(Azure) アプリケーションでこのエラーが発生しています:- セッション状態は、構成ファイルまたは Page ディレクティブで enableSessionState が true に設定されている場合にのみ使用できます...

URLを書き換えています(これにはserver.transferを使用しています)

ページに直接アクセスするか、Response.Redirect を使用してアクセスすると、エラーは発生しません。

何か案が?

以下のコードを使用しています。

Public Class URLRewriter IHttpModule を実装 Public Sub Init(ByVal inst As System.Web.HttpApplication) System.Web.IHttpModule.Init を実装 AddHandler inst.BeginRequest, AddressOf Me.OnBeginRequest End Sub

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.
4

0 に答える 0