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().

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

and press F12 go to the defination of this Method.

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

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

 

相关文章:

  • 2022-12-23
  • 2021-05-02
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
  • 2021-07-13
  • 2021-08-30
  • 2021-11-05
猜你喜欢
  • 2021-11-16
  • 2021-10-21
  • 2021-12-29
  • 2021-09-30
  • 2021-10-29
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案