asp.net mvc - What's the correct response to unauthorized HTTP request? -


I am writing a web application. I do not know what is the correct response for unauthorized requests, it is convenient for the user when The server responds with the 302 and redirects it to the login page. Although somewhere deep inside I think 401 is more accurate. I am also scared a bit if 302 can not be misinterpreted by search engines.

How do you respond to your unauthorized requests?


Edit

I am using ASP.NET MVC. It is not important from the theoretical perspective. However ASP.NET forms use the authentication 302 approach.

I also like the behavior when the user is guided after successfully login to the page on which he was requested. I'm not sure that this can be easily implemented from the 401 approach.

Send a 401 response, and include a login form on the page on which you can return it with Come on. (This does not include a link just on the login page, include the entire form in the correct form.)


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -