C# ASP.NET MVC 4路由问题

C# ASP.NET MVC 4路由问题,c#,asp.net,asp.net-mvc-4,asp.net-mvc-routing,C#,Asp.net,Asp.net Mvc 4,Asp.net Mvc Routing,我正在尝试在浏览器中访问此url: http://localhost:41359/account/login 以下是我从RouteConfig.cs获得的路线: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Routing; namespace CTHRC.Roti.Web.UI {

我正在尝试在浏览器中访问此url:

http://localhost:41359/account/login
以下是我从RouteConfig.cs获得的路线:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace CTHRC.Roti.Web.UI
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                name: "Account",
                url: "account/{action}/{id}",
                defaults: new { controller = "Account", action = "Login", id = UrlParameter.Optional }
            );

            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
    }
}
但当我尝试在浏览器中转到此URL时,会出现以下错误:

{"Message":No HTTP resource was found that matches the request URI 'http://localhost:41359/account'.","MessageDetail":"No type was found that matches the controller named 'account'."}
这里似乎一切都正常,但我还是有这个错误。这是我的账户管理员:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebMatrix.WebData;
using CTHRC.Roti.Domain.Api.Services;

namespace CTHRC.Roti.Web.UI.Controllers
{
    public class AccountController : Controller
    {
        [HttpGet]
        public ActionResult Login()
        {
            if (!WebSecurity.Initialized)
            {
                WebSecurity.InitializeDatabaseConnection("ModelContext", "Users", "Id", "UserName", autoCreateTables: true);
            }
            return View();
        }

        [HttpPost]
        public ActionResult Login(FormCollection form)
        {
            bool success = WebSecurity.Login(form["username"], form["password"], false);
            if (success)
            {
                string returnUrl = Request.QueryString["ReturnUrl"];
                if (returnUrl == null)
                {
                    Response.Redirect("/home/index?userID=" + WebSecurity.CurrentUserId);
                }
                else
                {
                    Response.Redirect(returnUrl);
                }
            }
            return View();
        }
        [HttpGet]
        public ActionResult Register()
        {
            if (!WebSecurity.Initialized)
            {
                WebSecurity.InitializeDatabaseConnection("UserDb", "Users", "Id", "UserName", autoCreateTables: true);
            }
            return View();
        }

        [HttpPost]
        public ActionResult Register(FormCollection form)
        {
            WebSecurity.CreateUserAndAccount(form["username"], form["password"], new { Email = form["email"], Language = form["language"] });
            Response.Redirect("/account/login");
            return View();
        }

        public ActionResult Logout()
        {
            WebSecurity.Logout();
            Response.Redirect("/account/login");
            return View();
        }

    }
}

我已经为这个问题挣扎了好几天了,我清理了我的解决方案,重新构建了我的解决方案,构建了我的解决方案,但我仍然会遇到这个错误。如果有人能帮助我,我将不胜感激。提前谢谢

如果您将您的
默认
路线放在您的
帐户
路线之后会发生什么情况?我的默认路线放在我的帐户路线之后,不管顺序如何,当我转到:
http://localhost:41359/account/login
根据错误消息,您似乎没有在URL中传递操作名称。还有一件事,如果您的应用程序中有两个项目或区域,那么您还必须在路由中包含程序集名称,以便MVC可以找到正确的控制器。并确保控制器位于正确的目录中。。它不应该在Web API控制器中映射此url