[英]Use of Response.End in an MVC3 Action
我正在嘗試在我的 MVC3 站點中執行本文所建議的操作。 但是,我不確定是否可以在 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
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.