ASP.NET cannot access files without aspx without login (.js, .html, etc.).

I started a new solution with a website project and a logical project for all my class files.

I copied the web.config file that I use for all my other projects and just changed the database name in the connection string. When I run this project for debugging, it will prevent me from accessing the files until I login. This includes javascript files, html files, css files, etc.

In all of my projects, the only files that require a user login to access are files .aspx

and .asmx

. The web.config security settings for all my projects are as follows:

<authentication mode="Forms">
    <forms loginUrl="/Default.aspx" name="ADMINAUTH2" cookieless="UseCookies"/>
</authentication>
<authorization>
    <deny users="?"/>
</authorization>

      

If I set test.htm as the start page, when I run the debugger, the url is routed directly: http://localhost:2154/Default.aspx?ReturnUrl=%2ftest.htm

In VS, on my solution exponent, under the script documents that are loaded, any javascript file is displayed as: Default.aspx?ReturnUrl=/Functions.js

etc. and no css files are applied.

I tried creating a new web.config file and only adding my properties and connection string to no avail.

I am completely confused as this works in all my other projects, just not this last one!

+2


source to share


1 answer


Have you tried this project for IIS or are you just running it from Visual Studio?

The authentication rules specified in web.config

apply to all files that are processed by the ASP.NET ISAPI filter. By default, IIS is such a thing as .aspx

, and .asmx

etc. - as you expect. However, Visual Studio Web Server handles everything through ASP.NET, so the authentication rules apply to all files.



On the other hand, this information can be quite useful when you really want to protect static assets in production - just do it by setting IIS to have ASP.NET handle these file extensions.

+1


source







All Articles