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