【发布时间】:2015-10-01 11:54:28
【问题描述】:
在 Asp.net MVC 项目中,我在登录后将用户重定向到另一个页面。
在开发环境中,我所有的会话变量都返回 null。
在生产环境中,这可以正常工作,并且可以正确检索会话变量。
有人能解释一下为什么在开发环境中所有变量都为空。
[AllowAnonymous]
[HttpPost]
public ActionResult Login(LoginModel model, string returnUrl)
{
// Some validations
if (Url.IsLocalUrl(returnUrl))
{
var urlDeCoded = HttpUtility.UrlDecode(returnUrl);
var htmlDecoded = HttpUtility.HtmlDecode(urlDeCoded);
return Redirect(htmlDecoded);
}
}
/// Retreiveing session variables
var vm = SessionData.GetCurrentObject<MembershipWizardViewModel>();
在 web.Config 中,两个 Envirnoments 上的 sessionState 值相同,即“InProc”
【问题讨论】:
-
每次都这样吗?
-
是的..每次都会发生..
-
我发现因为我在一个页面中有一个部分,并且登录控制在部分内......登录时父页面不会刷新,所以它会继续失去会话。我需要一种在登录时刷新父页面的方法。
标签: asp.net asp.net-mvc c#-4.0 session-variables url-redirection