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

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"];
}

 

posted @ 2015-10-05 17:36  Gester.Lin  阅读(199)  评论(0编辑  收藏  举报