0
我想设置路由的博客,就像这样:ASP.net MVC路由的博客
www.smth.com/news/ - >显示所有新闻 www.smth.com/news /管理员 - 新闻 www.smth.com/news/this-is-a-post-name>管理面板 - >单后
我已经厌倦了像这样,但没有运气:
routes.MapRoute("News", "news/{title}",
new { controller = "News", action = "Post", title = UrlParameter.Optional }
);
routes.MapRoute("Default", "{controller}/{action}/{id}",
new {controller = "Home", action = "Index", id = UrlParameter.Optional}
);
控制器:
public ActionResult Post(string title)
{
if (string.IsNullOrEmpty(title))
{
return RedirectToAction("Index", "News");
}
if (title.ToLower() == "admin")
{
return RedirectToAction("Admin", "News");
}
return View("Single");
}
我得到的错误是:
的Firefox已经检测到服务器重定向此地址的请求的方式,将永远不会完成。