这以前没有发生过,但突然之间我不再使用我的默认路线了。我的主页转到http://localhost:2222/assets/images/30?Controller=home&Action=index
. 为什么会发生这种情况?
我注意到当我在家庭控制器上进行操作时它工作正常,但是如果我转到另一个控制器,就会出现这个问题。
@foreach(var t in MVC.Home.Index().GetRouteValueDictionary())
{
<span>@t.Key - @t.Value</span>
}
Area - Controller - home Action - index
关联
@Html.ActionLink("Home", MVC.Home.Index())
全球.asax
routes.Add(
"Images",
new Route(
"assets/images/{Id}",
new RouteValueDictionary(),
new RouteValueDictionary { { "Id", "\\d+" } },
new ImageRouteHandler(new ImageHandler())
)
);
routes.MapRouteLowercase(
"Default",
"{controller}/{action}",
new { controller = "Home", action = "Index", area="" }
);
家庭控制器.cs
public partial class HomeController : SiteController
{
public virtual ActionResult Index()
{
var model = new HomeViewModel();
return View(model);
}
T4MVC.cs
public class ActionNamesClass {
public readonly string Index = ("Index").ToLowerInvariant();
}