我的 asp.net 会员授权有问题,我配置了我的主要 Web 配置,如下所示:
<connectionStrings>
<add name="xxx" connectionString="Data Source=; Initial Catalog=; Integrated Security=;" providerName="System.Data.SqlClient" />
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer"
connectionString="Data Source=; Initial Catalog=; Integrated Security=;"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<roleManager enabled="true" defaultProvider="MyProvider">
<providers>
<add name="MyProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="Devices"
applicationName="MembersTable" />
</providers>
</roleManager>
<membership defaultProvider="MyProvider">
<providers>
<add name="MyProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="" />
</providers>
</membership>
<authentication mode="Forms">
<forms loginUrl="Denied.aspx" name=".ASPXFORMSAUTH"/>
</authentication>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>`
在指定的文件夹中我的配置看起来像
<configuration>
<location>
<system.web>
<authorization>
<allow roles="role1"/>
<deny users="*" />
</authorization>
</system.web>
</location>
</configuration>
但是登录后我无法访问文件夹文件,它会在Denied.aspx
我使用方法验证用户Membership.ValidateUser
和调用页面的页面上返回我Response.Redirect
。这是否足够,或者我需要一种不同的方式来请求受保护的页面
if (
Membership.ValidateUser(this.txtUsername.Text, this.txtPassword.Text))
{
Response.Redirect("/tempUser/Role1Page.aspx");
}
else {
Response.Redirect("Denied.aspx");
}