Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 如果我在MVC中使用SimpleMembership,是否需要在ASP.NET中应用会话以进行登录/注销?_Asp.net Mvc_Session_Authentication_Logout_Simplemembership - Fatal编程技术网

Asp.net mvc 如果我在MVC中使用SimpleMembership,是否需要在ASP.NET中应用会话以进行登录/注销?

Asp.net mvc 如果我在MVC中使用SimpleMembership,是否需要在ASP.NET中应用会话以进行登录/注销?,asp.net-mvc,session,authentication,logout,simplemembership,Asp.net Mvc,Session,Authentication,Logout,Simplemembership,我是web开发新手,所以在使用SimpleMembership时是否需要实现会话 因为我在注销后对后退按钮有问题。它会转到上一页而不是登录。所以我在global.ascx中添加了下面的代码。它现在工作得很好 Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1)); Response.Cache.SetNoStore(); 因

我是web开发新手,所以在使用SimpleMembership时是否需要实现会话 因为我在注销后对后退按钮有问题。它会转到上一页而不是登录。所以我在global.ascx中添加了下面的代码。它现在工作得很好

Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();

因此,我的问题是,我是否可以在没有会话的情况下运行我的应用程序,其中有用户身份验证,即有用户帐户,并且有登录和注销功能。

您可以使用默认的
SimpleMembership
功能登录和注销:

登录:

bool success = WebSecurity.Login(form["username"], form["password"], false);
注销:

 WebSecurity.Logout();

有关详细信息,请参阅MSDN链接

您刚才误解了我的问题,我的问题是我是否需要在我的应用程序中应用会话,或者SimpleMembership足以处理会话提供的内容,例如,在注销后返回按钮将用户带到主页后SimpleMembership足以处理登录和注销。