I have an application using ASP.NET Forms Authentication. For the most part, it works great, but I'm trying to add support for a simple API through an .ashx file. I want the ashx file to have additional authentication (i.e. if you do not provide an authentication header, then it just works anonymously). But, depending on what you are doing, I want to require authentication under certain conditions.
I thought it would be easy to respond to the 401 status code if the required authentication was not provided, but it looks like the Autodesk Forms module intercepts this and responds with a redirect to the login page instead. I mean, if my ProcessRequest method looks like this:
public void ProcessRequest(HttpContext context) { Response.StatusCode = 401; Response.StatusDescription = "Authentication required"; }
Then instead of getting the 401 error code on the client, as I expect, I get a 302 redirect to the login page.
For nornal HTTP traffic, I see how it would be useful, but for my API page, I want 401 to go through unchanged so that the client client can respond to it programmatically.
Is there any way to do this?
Dean Harding May 15 '10 at 8:16 2010-05-15 08:16
source share