我有使用母版页的Web应用程序。我希望登录页面成为用户导航到此站点时显示的第一个页面。登录页面是内容页面。当我使用Asp.Net演示和配置网站提供设置安全性时,我的应用程序不呈现任何样式。是否有更好的教程来锁定整个Web应用程序以及如何使用安全性?
答案 0 :(得分:3)
您需要允许匿名访问web.config文件中的资源(CSS,JavaScript等)。如果不这样做,那么在您登录之前不会提供服务。
阅读Setting authorization rules for a particular page or folder in web.config
示例:
<configuration>
<location path="mystyles.css">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
</configuration>
答案 1 :(得分:0)
如果您已使用表单身份验证,则只需在web.config中添加以下部分
<location path="App_Themes"> (location of your style resource)
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
因此样式将具有匿名访问权限。用于自动将匿名用户重定向到登录页面 您必须按以下方式添加登录网址
<authentication mode="Forms">
<forms loginUrl="~/Login.aspx" protection="All" path="/" timeout="30"></forms>
</authentication>