你的位置:首页 > ASP.net教程

[ASP.net教程]Part 2 How are the URLs 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"];}