に設定されていない私はこの問題は、毎回セッションがオブジェクトであることはnullであるということである私のGlobal.asaxASP.NET MVCセッションがnullです。セッション変数は
protected void Application_AcquireRequestState(object sender, EventArgs e)
{
if (HttpContext.Current.Handler is IRequiresSessionState)
{
if (Request.IsAuthenticated)
{
if (HttpContext.Current.Session[this.MemberShipProvider.PrincipalSessionKey] != null)
{
CxPrincipal principal;
try
{
principal = (CxPrincipal)HttpContext.Current.Session[this.MemberShipProvider.PrincipalSessionKey];
}
catch
{
principal = null;
}
HttpContext.Current.User = principal;
Thread.CurrentPrincipal = principal;
}
else
{
var identity = new CxIdentity("admin", 1, "", true);
CxPrincipal principalLogin = new CxPrincipal(identity, 1);
HttpContext.Current.Session[this.MemberShipProvider.PrincipalSessionKey] = principalLogin;
HttpContext.Current.Session[SessionName.CurrentUser] = "Admin User";
HttpContext.Current.User = principalLogin;
Thread.CurrentPrincipal = principalLogin;
this.FormServiceProvider.SignIn("admin", false); // this is equal to FormsAuthentication.SetAuthCookie
}
}
}
}
に次のコードを持っています。ここだけでなく、自分のアプリケーションでセッションを使用することもできません。セッションがリセットされているか、そのようなものです。
マイアプリに追加してログインする必要はありません。したがって、私はアプリケーションでSession.ClearまたはSession.Abandonを使用していません。
どうすれば私のセッション変数が設定されていないのですか?あなたが実装する必要があります(とメガバイトを空のまま)
[ASP.NET MVCでのセッション状態を有効にする]の可能な重複(http://stackoverflow.com/questions/ 2620520/enable-session-state-in-asp-net-mvc) – Krumelur
デバッグから何が伝えられましたか? –
@AntPデバッグ中にセッションオブジェクトがありますが、変数が設定されていません。 – progrAmmar