Вот ошибка:
The incoming request does not match any route.
По сути, я обновил с Preview 1 до Preview 2 и избавился от множества ненужных вещей по отношению к областям (как описано Филом Хааком). Это не сработало, поэтому я создал совершенно новый проект, чтобы проверить, как с ним справляются в Preview 2. Файл Default.aspx
больше не существует и содержит следующее:
public void Page_Load(object sender, System.EventArgs e)
{
// Change the current path so that the Routing handler can correctly interpret
// the request, then restore the original path so that the OutputCache module
// can correctly process the response (if caching is enabled).
string originalPath = Request.Path;
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
HttpContext.Current.RewritePath(originalPath, false);
}
Ошибка, которую я получил, указывает на строку httpHandler.ProcessRequest(HttpContext.Current);
, но в более новых проектах ничего этого даже не существует. Чтобы проверить это, я быстро удалил Default.aspx
, но потом ничего не получалось, я даже не получил никаких ошибок. Вот некоторые выдержки из кода:
Global.asax.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace Intranet
{
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
AreaRegistration.RegisterAllAreas();
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = "" }
);
}
protected void App_Start()
{
RegisterRoutes(RouteTable.Routes);
}
}
}
Обратите внимание на регистрацию области, так как это то, что я использую.
Routes.cs
using System.Web.Mvc;
namespace Intranet.Areas.Accounts
{
public class Routes : AreaRegistration
{
public override string AreaName
{
get { return "Accounts"; }
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute("Accounts_Default", "Accounts/{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" });
}
}
}
Проверьте последние документы для получения дополнительной информации по этой части. Это зарегистрировать область. Файлы Routes.cs находятся в корневой папке каждой области.
Приветствия