Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.NET not applying my CSS files

Tags:

c#

.net

css

asp.net

My site located in folder /website

In browser it opens by url http://localhost:52912/website/

My Default page amd master page both located in root catalog

in Default.aspx i include my master page like:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default"  MasterPageFile="WTF.master" %>

In my WTF.mater i include css file:

<link href="~/css/reset.css" runat="server" rel="stylesheet" type="text/css" media="screen" />

when i run the site and look his source code in mozilla, i see css file link as:

<link href="css/reset.css" rel="stylesheet" type="text/css" media="screen" />

so, full url will be http://localhost:52912/website/css/reset.css which is correct

-css file EXISTS

-No errors in firebug like "404 not found - reset.css"

-No errors when debugging project

I can't even open this file by direct link in browser ( http://localhost:52912/website/css/reset.css ) or by link in mozilla source code viewer

It returns http://localhost:52912/website/default.aspx?ReturnUrl=%2fcss%2freset.css and i remains on the same page

I tried a whole bunch of various combinations and advices from google - nothing helps

What the..???

SOLVED: by adding

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

in web.config

like image 649
johnode Avatar asked Dec 15 '22 15:12

johnode


1 Answers

That's because you have forms authentication turned on and you haven't allowed that css folder public access. Try adding this to the web.config:

<location path="css">
    <system.web>
        <authorization>
            <allow users="*" />
        </authorization>
    </system.web>
</location>
like image 113
mattytommo Avatar answered Jan 07 '23 09:01

mattytommo