1
我已经为我的网站设置了FormAuthentication。web.config中的<location>命令是否重要?
我想允许匿名访问登录页面及其资源(js,css,images)。
我已经添加到web.config。那里的订单有关系吗?
<configuration>
<configSections>
<section name="hibernate-configuration"
type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<appSettings>
<add key="webpages:Version" value="1.0.0.0" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<location path="~/Authentication.htm">
<system.web>
<authorization>
<deny users="*" />
</authorization>
</system.web>
</location>
<location path="~/Resources">
<system.web>
<authorization>
<deny users="*" />
</authorization>
</system.web>
</location>
<location path="~/js">
<system.web>
<authorization>
<deny users="*" />
</authorization>
</system.web>
</location>
<location path="~/Images">
<system.web>
<authorization>
<deny users="*" />
</authorization>
</system.web>
</location>
<location path="~/Controllers">
<system.web>
<authorization>
<deny users="*" />
</authorization>
</system.web>
</location>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
.....
</assemblies>
</compilation>
<authentication mode="Forms">
<forms name="Login" loginUrl="~/Authentication.htm"
protection="All" path="/" timeout="30" />
</authentication>
<authorization>
<deny users ="?" />
<allow users = "*" />
</authorization>
为什么我还添加到路径的验证错误?
Authentication.htm?ReturnUrl=%2fResources%2fScripts%2fjquery-1.7.1.min.js:1Uncaught SyntaxError: Unexpected token <
Authentication.htm?ReturnUrl=%2fjs%2fCommon.js:1Uncaught SyntaxError: Unexpected token <
Authentication.htm?ReturnUrl=%2fjs%2fAuthentication.js:1Uncaught SyntaxError: Unexpected token <
它没有帮助。我想允许非授权用户在登录页面(js,css,images)上获取所有相关内容。写完你的配置后,我仍然没有得到Imgaes和脚本。 – 2012-03-09 20:20:38
从Visual Studio运行之前,我已经看到过它,但它在部署到IIS时仍然可以工作。 – jrummell 2012-03-09 20:55:26
问题在于'〜'。我认为这一点更加清楚,但是它失败了相对路径 – 2012-03-09 21:06:45