开发者

ASP.NET MVC multiple query string parameter

开发者 https://www.devze.com 2022-12-16 09:31 出处:网络
How do I design my URL to match my function like this: public开发者_JAVA百科 ActionResult GetStuff(string name, string address, double latitude, double longitude)

How do I design my URL to match my function like this:

public开发者_JAVA百科 ActionResult GetStuff(string name, string address, double latitude, double longitude)
{ }


Add a route with a signature that has all those parameters in it.

routes.MapRoute("myRoute",
                "{controller}/{action}/{name}/{address}/{latitude}/{longitude}",
                new { controller = "Home", 
                      action = "GetStuff", 
                      latitude=0.0, 
                      longitude =0.0, address="", name = "" }
           );

If you just intend to POST data to that action method, then the parameter names in your method signature can just match named input fields on your form instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号