I was wondering how I can access the GET parameter in url's like ?returnTo=url
I'm using MVC3 with C# and would like to get the value in a Controller. I've snooped around in the Request object, which has the values I need in the "Query" property.
Do I have to parse that QueryString manually or is there an easier way?
No, you don't have to parse manually. MVC3 uses model binding automatically. It means that if you add returnTo string parameter to your action method, MVC will automatically extract value from query string and initialize your action parameter. Default model binder tries to extract parameter values from Request.QueryString, Request.Form, RouteData. You can override or change part of behaviour if you implement custom model binder or register custom value provider. For more info take a look at Model Binding
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With