【发布时间】:2020-09-21 07:35:51
【问题描述】:
我想在 .net 中实现基本身份验证。所以在这里我不想要一个 aspx 页面。
我只需要 web.config 文件,它应该要求我输入用户名和密码(如果我没记错的话,我们可以让浏览器要求输入用户名和密码。)
目前我有下面的代码需要我想删除的 login.aspx 页面。
<?xml version="1.0"?>
<configuration>
<system.web>
<customErrors mode="Off"/>
<compilation debug="false" />
<authentication mode="Forms">
<forms>
<credentials passwordFormat="Clear">
<user name="abc" password="abc@123" />
</credentials>
</forms>
</authentication>
<!-- Unless specified in a sub-folder's Web.config file,
any user can access any resource in the site -->
<authorization>
<deny users="?" />
</authorization>
</system.web>
<system.webServer>
<modules>
<remove name="FormsAuthenticationModule" />
<add name="FormsAuthenticationModule" type="System.Web.Security.FormsAuthenticationModule" />
<remove name="UrlAuthorization" />
<add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule" />
</modules>
</system.webServer>
</configuration>
【问题讨论】:
-
@Martheen 感谢您的快速响应,但是否可以从 web.config 文件中处理?我不需要任何其他文件,我只想通过 web.config 文件完成所有内容
-
提示输入用户名和密码需要JavaScript代码。
-
哦,不,考虑到 this asker 最终会为它创建一个完整的 HttpModule
-
@Martheen 不能只使用 web.config 吗?