1
我有类似下面的地址:在MVC路由中设置区域注册时可以使用通配符吗?
www.stack.com/content-00000/solutions-about
我的路线注册(未经证实,但也许90%还行)看起来是这样的:
public class ContentAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Content";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Content_default",
"content-{id}/{title}",
new { controller = "Server", action = "Get" },
new { id = @"^\d{5}$" }
new { title = UrlParameter.Optional }
);
}
}
有人能确认这是否是正确的方法对我来说做路线
a) Go to the "Content" Area
b) Go to the "Server" Controller
b) Go to the "Get " action
c) Five digits that follow will be put into a parameter called id?
此外,我怎么能做出这种去到另一个动作,如“错误”如果没有后面五个数字的“内容 - ”?