Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to route legacy QueryString parameters in ASP.Net MVC 3?

I am using a third party service that does an async callback to a URL I provide to them. So I tell them to use http://www.mysite.com/Status/Incoming. This must obviously map to an Incoming() method on my StatusController.

However, what I don't have control over is the format of the parameters they call my URL with. E.g. They will do a callback such as: http://www.mysite.com/Status/Incoming?param1=val1&param2=val2&param3=val3

I want to map this to the parameters of my action method: Incoming(string param1, string param2, int param3)

How do I do this?

I have found a lot of stuff about custom routing, but nothing about legacy QueryString parameters.

like image 420
Jacques Bosch Avatar asked Dec 06 '25 13:12

Jacques Bosch


1 Answers

There is no such thing as legacy query string parameters. There are query string parameters and they are part of the HTTP specification. And assuming that the http://www.mysite.com/Status/Incoming?param1=val1&param2=val2&param3=val3 url is called you don't need any route to make it map to the following action (the default route will do just fine):

public ActionResult Incoming(string param1, string param2, string param3)
{
    ...
}

The default model will take care of binding those values.

like image 92
Darin Dimitrov Avatar answered Dec 10 '25 12:12

Darin Dimitrov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!