How to allow an anonymous user access to some given page in MVC?

前端 未结 2 1721
臣服心动
臣服心动 2020-11-30 03:38

I have enabled form authentication in my ASP.NET MVC web application. I want to allow anonymous users access only to some specific pages, including Register.cshtml for inst

2条回答
  •  眼角桃花
    2020-11-30 04:19

    In the Web.config i had the below authorization

    
        
    
    

    this causes the

    [AllowAnonymous]
    

    not work correctly, i had to remove that authorization of my Web.config, and in all the controllers put the line

    [Authorize]
    

    before the declaration of the class, to work correctly.

提交回复
热议问题