我正试图在我的MVC3网站上做this article建议的事情。但是,我不确定我可以在我的Action中使用Response.End。
我的问题是,如果HttpContext.User == null,如何从我的Action中返回401状态代码?
public ActionResult WinUserLogOn(string returnUrl) {
var userName = string.Empty;
if (HttpContext.User == null) {
//This will force the client's browser to provide credentials
Response.StatusCode = 401;
Response.StatusDescription = "Unauthorized";
Response.End();
return View("LogOn"); //<== ????
}
else {
//Attempt to Log this user against Forms Authentication
}