简体   繁体   中英

MVC Authentication bypass for a controller/action

I am using MVC with forms authentication and I need authentication bypass for one of my controllers, is it possible to bypass authentication for Controller(s)/Action(s).

I tried adding the below given configurations in the web.config file. But, that's not working for me.

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

Can anyone help in this regard.

Something like

[Authorize]
public class ValuesController : ApiController
{
    [AllowAnonymous]
    public HttpResponseMessage Get() { ... }

    public HttpResponseMessage Post() { ... }
}

from https://learn.microsoft.com/en-us/as.net/web-api/overview/security/authentication-and-authorization-in-as.net-web-api ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM