0

I have a similiar problem as the user here: Asp.NET not applying my CSS files

but when adding the code below to my web.config nothing happens.

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

The css file is still not loading. When I try to open it in a web browser by viewing the source, it opens a blank page with the correct URL (http://localhost/css/style.css). The only time when css is applied, is when I run the application from Visual Studio.

My web.config file is

<?xml version="1.0" encoding="UTF-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <connectionStrings>
    <add name="EDCConnectionString" connectionString="Data Source=.;Initial Catalog=EDC;Persist Security Info=True;User ID=web;Password=web" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <compilation targetFramework="4.5.2" debug="true">
      <assemblies>
        <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
      </assemblies>
    </compilation>
    <httpRuntime targetFramework="4.5.2" />
    <authentication mode="Forms">
      <forms defaultUrl="~/Home.aspx" loginUrl="~/Login.aspx" slidingExpiration="true" timeout="2880" />
    </authentication>
  </system.web>
  <location path="css">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>
  <appSettings>
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
  </appSettings>
    <system.webServer>
        <security>
            <requestFiltering>
                <fileExtensions>
                    <add fileExtension=".css" allowed="true" />
                </fileExtensions>
            </requestFiltering>
        </security>
    </system.webServer>
</configuration>
2
  • Can you please confirm if your css file path is correct on web.config? i.e. <location path="css">, I mean if css folder is not inside any other folder Commented Jan 10, 2016 at 19:39
  • Yes, the path is correct. It must be something with IIS on my computer. Some setting or something. Because I copied the source data to another IIS server and it works fine there. Commented Jan 10, 2016 at 20:47

1 Answer 1

0

not sure what file structure you may have setup, but it's worth pointing out that your location node does not have the root folder noted:

<location path="css">

Try

<location path="~/css">

Or however you have it set up. Failing that, assuming you have a site.master and a bundle.config you can always add the css file there.

Hope it helps, Apex

Sign up to request clarification or add additional context in comments.

1 Comment

Still same... but it must be something with IIS on my computer...Because I tryed code on another IIS server and it works fine there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.