Setting Autorization rules for ashx handler in ASP.NET MVC 3 application

前端 未结 1 1899
轮回少年
轮回少年 2021-01-28 10:55

I am implementing a javascript file upload functionality in my MVC 3 application and therefore I need to use Http Handler (.ashx) to allow large file upload. Now I need to someh

相关标签:
1条回答
  • 2021-01-28 10:59

    You could use the <location> section in your web.config to deny access to ~/upload.ashx to anonymous users:

    <location path="upload.ashx">
        <system.web>
            <authorization>
                <deny users="?" />
            </authorization>
        </system.web>
    </location>
    

    Remark: never use the <location> tag to control authorization with ASP.NET MVC controller actions and routes. Use the built-in [Authorize] attribute to decorate the corresponding controller/action.

    0 讨论(0)
提交回复
热议问题