2015-04-22 95 views

回答

0

ASP.NET有一个可以使用的登录机制。要启用它,请在您的web.config文件中添加以下内容。将loginUrl属性更改为您自己的登录页面的路径。

<configuration> 
    <system.web> 
     <authentication mode="Forms"> 
      <forms loginUrl="~/login.aspx" timeout="28800" name="webappname" /> 
     </authentication> 
    </system.web> 
</configuration> 

要创建你需要调用FormsAuthentication.RedirectFromLoginPage,你可以看到下面

string username = ""; 
bool rememberme = true; 

// Implement your own login mechanism and if the user is authenticated 
// set the username to the variable and make this call below 
FormsAuthentication.RedirectFromLoginPage(username, rememberme); 

最后,注销用户的ASP.NET验证cookie,你可以简单地调用

FormsAuthentication.SignOut(); 

您也可以看到这个link,其中描述了类似的机制

0

NO。您不能让用户在请求页面时每次都登录

这就是Authenticationasp.net或任何Web应用程序中工作的方式,以便用户在进行身份验证后无需为每个页面进行身份验证。

希望你使用Forms Authentication。默认情况下Form Authentication使用Cookies存储SessionID

您可以通过设置以下值web.config文件中使用cookielessauthentication

<configuration> 
    <system.web> 
    <sessionState cookieless="true" 
     regenerateExpiredSessionId="true" /> 
    </system.web> 
</configuration> 

ASP.NET通过自动插入 一个唯一的会话ID为保持Cookie会话状态该网页的网址。

https://msdn.microsoft.com/en-us/library/ms178581%28v=vs.140%29.aspx

http://www.codeproject.com/Articles/2796/Cookieless-ASP-NET-forms-authentication

相关问题