【发布时间】:2011-08-10 18:55:28
【问题描述】:
这是控制器代码:
public ActionResult AddFriend(string username)
{
//Todo: Add functionality to add a friend.
//Then redirect to that same profile.
return RedirectToAction("Detail", "Profile", username);
}
username 的内容是 stapia.gutierrez,而不是 16 或类似的东西。
当我访问链接时:
http://localhost:9198/profile/friend/add/stapia.gutierrez
之所以调用上述动作,是因为我在 Global.asax 中创建了一个路由:
routes.MapRoute("AddFriend", // Route name
"Profile/Friend/Add/{username}", // URL with parameters
new { controller = "Profile", action = "AddFriend" } // Parameter defaults
);
点击后网址显示为:
http://localhost:9198/Profile/stapia.gutierrez?Length=16
有什么想法吗?
【问题讨论】:
标签: asp.net view controller asp.net-mvc-3