Nol
Nol

Reputation: 364

CSS on IIS deployed ASP.NET code disappearing for unauthorized users

I created an ASP.NET program the default way with VS 2012.
My Site.css is in the Content folder.
My WebConfig is altered to deny access to anyone not authorized eg "? users", except to reach the login page.

I recently made a new build, which didn't touch my CSS or paths or any accessibility of my pages, but despite having previously worked the CSS on the login page is now broken - unless you logout and get redirected to it. After refreshing it, it still returns to broken.

My question is less of "What specifically is causing this problem" but more "How can I find the root of this problem?"
I'm going to attempt making the content folder publicly accessible as my solution, but I'm still curious why something like this could happen.

Upvotes: 0

Views: 67

Answers (1)

Win
Win

Reputation: 62290

It seems that you disabled anonymous access to every files and folders in your application.

If so, you can create a web.config file inside Content folder with the following content to allow anonymous access back to every file inside that folder.

<?xml version="1.0"?>
<configuration>

  <system.web>
    <authorization>
      <allow users="*"/>
    </authorization>
  </system.web>

</configuration>

Or in application level web.config file you can add with the rest of the code.

<?xml version="1.0"?>
<configuration>

  <location path="Content">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>

</configuration>

Upvotes: 1

Related Questions