简体   繁体   English

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

[英]Allow anonymous access to a special file in Asp.Net

I started using dotless in my asp.net site which requires a special httphandler to work. 我开始在我的asp.net网站上使用dotless,这需要特殊的httphandler才能工作。 The site uses Forms Authentication. 该站点使用表单身份验证。 Here's the problem: When I'm logged in the request to http://example.org/stylesheets/mystyles.less works fine. 这是问题所在:当我登录到http://example.org/stylesheets/mystyles.less的请求时,效果很好。 It gives me back the appropriate css. 它给了我适当的CSS。 If I'm not logged in the request is denied and I'm redirected to the login page. 如果我没有登录,请求将被拒绝,然后将我重定向到登录页面。 Is there a way to allow this file to be accessed anonymously? 有没有办法允许该文件被匿名访问? This is not working: 这不起作用:

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

The problem is with the path syntax. 问题在于路径语法。

This does not work: 这不起作用:

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

This DOES work: 这样做的工作:

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

不知道这是否是问题,但是您在xml中缺少引号。

<location path="~/stylesheets">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP.NET web.config表单身份验证,拒绝匿名用户,允许匿名访问单个文件 - ASP.NET web.config Forms Authentication, deny anonymous users, allow anonymous access for single files 当站点具有全局AuthorizeAttribute时,ASP.NET允许匿名访问OData $ metadata - ASP.NET allow anonymous access to OData $metadata when site has global AuthorizeAttribute ASP.NET Web窗体授权允许匿名用户访问特定页面 - ASP.NET Web Forms Authorization allow access for anonymous user to specific pages ASP.Net MVC 3允许匿名白名单不起作用 - ASP.Net MVC 3 Allow Anonymous white list not working ASP.NET auth,排除root并允许匿名 - ASP.NET auth, exclude root & allow anonymous Asp.net只允许访问管理员 - Asp.net Allow access to Admin Only 在ASP.NET MVC的NumericUpDown EditorFor()中不允许使用特殊字符 - Do not allow special characters in NumericUpDown EditorFor() in ASP.NET MVC 如何允许asp.net密码包含特殊字符,如“ &lt;”和“&gt;” - How to allow asp.net passwords to include special characters like “<” and '“>” Asp.net Windows 身份验证拒绝匿名访问 - Asp.net Windows Authentication Deny Anonymous Access 卡西尼修改为ASP.NET 3.5的匿名访问 - Cassini Modification for Anonymous Access for ASP.NET 3.5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM