ASP.NET Membership Remains Authenticated

So, my application is odd in that when you log in, you stay in the system for one or two pages, and then lose. My settings are as follows:

 <authentication mode="Forms">    
     <forms name=".ASPXFORMSAUTH"  timeout="20"/>
  </authentication>

 <authorization>
<allow users="*" />
</authorization>
 <membership defaultProvider="MySqlConnection" userIsOnlineTimeWindow="45">
 <providers>
    <clear />
    <add name="MySqlConnection" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MySqlConnection" 
applicationName="HQChannel" 
enablePasswordRetrieval="true" 
enablePasswordReset="true"
requiresQuestionAndAnswer="false" 
requiresUniqueEmail="true" 
passwordFormat="Hashed" 
minRequiredNonalphanumericCharacters="0" 
minRequiredPasswordLength="6" />
 </providers>
 </membership>

Thank you for your help.

+3
source share
2 answers

Two things stand out for me here. First, do you allow * users instead? users * means anonymous ,? means authentication. I would change it to the following and see if that helps ...

<authorization>
   <allow users="?" />
   <deny users="*" />
</authorization>

, slideExpiration = "true" . - 20 ...

<forms name=".ASPXFORMSAUTH" timeout="20" slidingExpiration="true" />
+3

, , .

FormsAuthenticationTicket ticket = new FormsAuthenticationTicket
(
   1, // version
   txtEmail.Text, // name
   DateTime.Now, // issueDate
   DateTime.Now.AddMinutes(30), // expiration
   false, // isPersistent
   roles, // userData
   FormsAuthentication.FormsCookiePath // cookiePath
 );

, web.config .

+1

Source: https://habr.com/ru/post/1702652/


All Articles