我想得到类似这样的访问规则
https://twitter.com/用户名
该怎么做?
我首先在路由里:
routes.MapRoute(
"Profile",
"{userName}",
new { contorller="Profile",action="Index", userName= ""}
);
然后Action里这样写:
public ActionResult Index(string userName)
{
return View(db.States.Where(p=>p.IsPubishBy==userName.ToLower()));
}
页面里这样写:
<%= Html.RouteLink("Profile", "Profile", new { userName = Page.User.Identity.Name })%>
Url显示没错可是访问提示无法找到资源
https://twitter.com/用户名
该怎么做?
我首先在路由里:
routes.MapRoute(
"Profile",
"{userName}",
new { contorller="Profile",action="Index", userName= ""}
);
然后Action里这样写:
public ActionResult Index(string userName)
{
return View(db.States.Where(p=>p.IsPubishBy==userName.ToLower()));
}
页面里这样写:
<%= Html.RouteLink("Profile", "Profile", new { userName = Page.User.Identity.Name })%>
Url显示没错可是访问提示无法找到资源
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货