本文介绍了用户始终保持未认证状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试进行表单身份验证,但可能是我的代码中的某些地方出了问题.即使成功登录,用户也总是未经身份验证:
在我的Web confing文件中,我有:
Im trying to do form authentication but probably some thing wrong is some where in my code.the user always reamins unauthenticated even after successful login in:
in my web confing file i have:
<<pre lang="xml">?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="ADConnection" connectionString="LDAP://localhost:23766/WebSite21"/>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
<add name="ConnectionString" connectionString="Data Source=FNUILTP10\SQL2005;Integrated Security=True" providerName="System.Data.SqlClient"/>
<add name="ConnectionString2" connectionString="Data Source=FNUILTP10\SQL2005;Integrated Security=True" providerName="System.Data.SqlClient"/>
<add name="RecordsManagementConnectionString" connectionString="Data Source=FNUILTP10\SQL2005;Initial Catalog=RecordsManagement;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<httpRuntime maxRequestLength="2097151" executionTimeout="360000"/>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.DirectoryServices.AccountManagement, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="Microsoft.Office.Tools.Word, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="Microsoft.Office.Tools.Excel, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="Microsoft.MSXML, Version=8.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation>
<authentication mode="Forms">
<forms loginUrl="Login.aspx" protection="All" path="/" requireSSL="true" timeout="2880">
</forms>
</authentication>
<identity impersonate="true"/>
<authorization>
<deny users="?"/>
</authorization>
<membership defaultProvider="MyADMembershipProvider">
<providers>
<add name="MyADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="ADConnection" attributeMapUsername="sAMAccountName"/>
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/"/>
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/"/>
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration
>
并以以下一种网络形式:
and in one of the web forms:
protected void Page_Load(object sender, EventArgs e)
{
if (User.Identity.IsAuthenticated==false)
{
Response.Redirect("Login.aspx");
}
}
即使提供正确的用户名和密码,它也总是返回登录页面...
It always returns to the login page even correct username and password is provided...
推荐答案
这篇关于用户始终保持未认证状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!