您的位置:首页 > 移动开发

Part 2 How are the URL's mapped to Controller Action Methods?

2015-10-05 17:36 555 查看
Part 2 How are the URL's mapped to Controller Action Methods?

The answer is ASP.NET Routing.Notice that in Global.asax we have RegisterRoutes().



and press F12 go to the defination of this Method.



ASP.NET MVC will automatically pass any query string or form post parameters named "name" to index action method when it is invoked.

public string Index(string id,string name)
{
return "Id="+id+" Name="+name;
}
public string Index(string id)
{
return "Id="+id+" Name="+Request.QueryString["name"];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: