asp.net - Forms authentication: disable redirect to the login page -


I have an app that uses ASP.NET form authentication. For the most part, this is working great, but I'm one. I am trying to add support for a simple API through an APC file. I want Ash file to be an alternative certification (i.e. if you do not provide an authentication header, it works anonymously). But, depending on the work you have done, I need certification under certain conditions.

I thought this would be a simple matter to answer with the status code 401 if the required authentication was not supplied, but it appears that the form authentication module is blocking it and instead of entering the login page Have to answer with the redirect. What do I mean if my process request method looks like this:

  public zero process request (HTTP contact reference) {Response.StatusCode = 401; reaction. Status statement = "authentication required"; }  

Instead of receiving a 401 error code on the client, I hope that, I am getting 302 redirects on the actually login page.

For nornal HTTP traffic, I can see how useful it will be, but for my API page, I want to go 401 through Unmodified so that the client-side collar is programmatically Can answer it.

Is there any way to do this?

ASP.NET 4.5 added Boolean property.

Public Zero Processing Request (HTTP Contact Reference) {Response.StatusCode = 401; reaction. Status statement = "authentication required"; reaction. SuppressFormsAuthenticationRedirect = true; }

Comments