c# - Does order of <location> in web.config matters? -


i have set formauthentication website.

i want allow annonymous access login page , resources (js, css, images).

i have added web.config. order there matter?

<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> 

why still authentication errors path have added ?

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 < 

your root setting denies unauthenticated users (?) , location settings deny users (*).

you meant this:

<!-- web application root settings --> <authorization>    <deny users ="?" /> </authorization>  <!-- login , static resources --> <location path="~/images">   <system.web>     <authorization>       <allow users="*" />     </authorization>   </system.web> </location> 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -