我設置到我的網站。<Loaction>在web.config中不起作用
我想允許進入登錄頁面
?
是匿名的,*
是每個人。有什麼不同?我加
<location>
到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>
爲什麼我仍然得到驗證錯誤,因爲我已經加入到<location>
的路徑?
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 <
你在哪裏加位置標籤?該文件的順序和結構絕對重要。 – 2012-03-09 10:58:01
我錯過了我的帖子中的qout,所以我的webconfig變得透明。修改 – 2012-03-09 11:00:35
@EladBenda:是的,這有點麻煩 - 如果你碰巧在編號(或項目符號)列表中有代碼或配置,你需要用8(而不是4)個字符來使代碼格式化...... 。 – 2012-03-09 11:06:40