1
我收到如下所示的錯誤。在我的代碼執行到達返回View()或返回重定向到動作之前,我得到了這種錯誤方式。無法找到該資源。請求的URL:/ Area/Controller/undefined
我有設置的區域。我也張貼區域註冊部分檢查是否有任何錯誤。我檢查了文件夾的拼寫。一切運行良好,直到有任何部分通過實體框架從數據庫獲取數據。我很困惑,究竟是什麼導致了這個問題。
'/'應用程序中的服務器錯誤。
無法找到該資源。
說明:HTTP 404.您正在查找的資源(或其某個依賴項)可能已被刪除,名稱已更改或暫時不可用。請檢查以下網址並確保它拼寫正確。
請求的URL:/管理/主頁/未定義
版本信息:Microsoft .NET Framework版本:4.0.30319; ASP.NET>版本:4.0.30319.18408
首頁控制器區域下
[HttpGet]
[Authorize]
public ActionResult Show()
{
return View();
}
public ActionResult Login()
{
return View();
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Login(string rememberMe, string UserName, string Password)
{
AuthenticateUser Authenticate = new AuthenticateUser();
if (Authenticate.isUserAuthentic(UserName, Password))
{
//the error page is rendered here ..
//even before reaching the return View portion or Redirect to action
FormsAuthentication.SetAuthCookie(UserName, false);
return RedirectToAction("Show");
}
else
{
return View();
}
}
DBCONTEXT DB = new DBCONTEXT();
public bool isUserAuthentic(string UserName, string Password)
{
bool Authentic = false;
admin_users User = DB.admin_users.SingleOrDefault(u => u.user_name == UserName);
if (User != null)
{
if (User.user_password == Password)
{
Authentic = true;
}
else
{
Authentic = false;
}
}
return Authentic;
}
public class AdminAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Admin";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Admin_default",
"Admin/{controller}/{action}/{id}",
new { controller = "Home", action = "Show", id = UrlParameter.Optional },
namespaces: new[] { "ProjectName.Areas.Admin.Controllers" }
);
}
}
請讓我知道如果有別的,我需要爲了使問題更加清晰分享。