Webforms HttpContext.Current.User.Identity.IsAuthenticated always true

EDIT: Can someone explain why I get "/" for username? See My Answer below

I created a new WebForms application in VS2013 (.NET 4.51) that included the β€œnew” Identity membership provider. I wanted to use an older membership provider, so I did the following.

  • Configured the necessary entries in web.config as follows:

:

 <membership defaultProvider="DefaultMembershipProvider">
   <providers><add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
      </providers>
 </membership>

and

<profile defaultProvider="DefaultProfileProvider">
  <providers>
    <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
  </providers>
</profile>
<roleManager defaultProvider="DefaultRoleProvider" enabled="true">
  <providers>
    <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
  </providers>
</roleManager>

I checked node authentication twice:

<authentication mode="Forms">
  <forms loginUrl="Account/Login" timeout="120" defaultUrl="/">
  </forms>
</authentication>

My login code is as follows:

if (Membership.ValidateUser(txtUserName.Text, txtPassword.Text))
{
   FormsAuthentication.RedirectFromLoginPage("/", chkRememberMe.Checked); 
}

and my exit code:

FormsAuthentication.SignOut();
Session.Abandon();
FormsAuthentication.RedirectToLoginPage();

HttpContext.Current.User.Identity.IsAuthenticated TRUE, , , :

  <!-- Entire site is secured -->
  <location path=".">
    <system.web>
      <authorization>
        <deny users="?" />
      </authorization>
    </system.web>
  </location>

? , Identity, , . , Identity, , VS2013.

.

0
1

, (WT....). , , , , . - .

:

System.Web.HttpContext.Current.User.Identity.Name

:

"/"

, :

Membership.ValidateUser(txtUserName.Text, txtPassword.Text)

. txtUserName.Text /

, : HOWTO , Identity ?

0

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