允许匿名访问Asp.Net中的特殊文件

Mic*_*cah 1 css asp.net forms-authentication dotless

我开始在我的asp.net网站上使用dotless,这需要一个特殊的httphandler来工作.该网站使用表单身份验证.这是问题所在:当我登录http://example.org/stylesheets/mystyles.less的请求时工作正常.它给了我适当的CSS.如果我没有登录,请求被拒绝,我被重定向到登录页面.有没有办法允许匿名访问此文件?这不起作用:

<location path="~/stylesheets">
    <system.web>
        <authorization>
            <allow users="*" />
        </authorization>
    </system.web>
</location>
Run Code Online (Sandbox Code Playgroud)

Mic*_*cah 9

问题在于路径语法.

这不起作用:

<location path="~/stylesheets">
    <system.web>
        <authorization>
            <allow users="*" />
        </authorization>
    </system.web>
</location>
Run Code Online (Sandbox Code Playgroud)

这个工作:

<location path="stylesheets">
    <system.web>
        <authorization>
            <allow users="*" />
        </authorization>
    </system.web>
</location>
Run Code Online (Sandbox Code Playgroud)