【发布时间】:2020-02-26 12:04:12
【问题描述】:
我正在测试使用 VS 2019 在 ASP.Net webform 应用程序中使用 ASP.Net Membership,默认情况下,当我创建新的 webform 应用程序时,它会为应用程序创建身份验证,我想在此应用程序中使用 ASP.Net Membership
我通过在 webconfig 中添加以下设置禁用了 Owin Identity autheticaltion
还为 ASP.Net Membership 添加了以下设置
<membership>
<providers>
<!--
ASP.NET Membership is disabled in this template. Please visit the following link https://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template
-->
<clear/>
<!-- ****ASP.Net Membership Code old not Identity ****-->
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="SQLConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="5" applicationName="/"/>
</providers>
</membership>
<profile>
<providers>
<!--
ASP.NET Membership Profile is disabled in this template. Please visit the following link https://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template
-->
<clear/>
<!-- ****ASP.Net Membership Code old not Identity ****-->
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="SQLConnectionString" applicationName="/"/>
</providers>
</profile>
<roleManager>
<!--
ASP.NET Membership Role is disabled in this template. Please visit the following link https://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template
-->
<providers>
<clear/>
<!-- ****ASP.Net Membership Code old not Identity ****-->
<add connectionStringName="SqlConnectionString" applicationName="/" name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider"/>
<add applicationName="/" name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider"/>
</providers>
</roleManager>
<authorization>
<allow users="?"/>
</authorization>
<system.web>下面的代码
我可以使用_login.aspx 页面登录,它重定向到_admin 目录页面下的default.aspx,但页面给我以下错误http://localhost:56849/_admin/Default.aspx
我检查过的连接字符串SQLConnectionString也很好..
“/”应用程序中的服务器错误。访问被拒绝。说明:一个 访问提供此服务所需的资源时发生错误 要求。服务器可能未配置为访问所请求的 网址。
错误消息 401.2.:未经授权:由于服务器原因登录失败 配置。验证您是否有权查看此目录 或基于您提供的凭据和身份验证的页面 Web 服务器上启用的方法。联系 Web 服务器的 管理员以获得更多帮助。
版本信息:Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.8.3928.0
我不确定为什么会发生这种情况,因为页面存在于 _admin 文件夹中并且 _login.aspx 正在验证用户并正确重定向它。
任何可能发生这种情况的指针,或者如果我错过了任何配置......
【问题讨论】:
标签: c# asp.net webforms asp.net-identity asp.net-membership