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" }
);
}
}
请让我知道如果有别的,我需要为了使问题更加清晰分享。