Ad
MVC- How To Get Parameter Value From Get Request Which Has Parameter Names Including Dot Characters
In MVC, I know we can get parameters from a get request like this:
Request:
http://www.example.com/method?param1=good¶m2=bad
And in controller
public ActionResult method(string param1, string param2)
{
....
}
But in my situation an external website sends me a get request like:
http://www.example.com/method?param.1=good¶m.2=bad
And in controller when i try to meet this request like as follow:
public ActionResult method(string param.1, string param.2)
{
....
}
I get build errors because of dot in variable name. How can i get these parameters ? Unfortunately i can not ask them to change parameter names.
Ad
Answer
Use the following code:
public ActionResult method()
{
string param1 = this.Request.QueryString["param.1"];
string param2 = this.Request.QueryString["param.2"];
...
}
Ad
source: stackoverflow.com
Related Questions
- → Function Undefined in Axios promise
- → AngularJS directive: "templateUrl" doesn't work while "template" works
- → JavaScript in MVC 5 not being read?
- → URL routing requires /Home/Page?page=1 instead of /Home/Page/1
- → NumericTextBox Loses Value using Html.TextBoxFor, not HTML
- → Does the fact that every page is reachable through www.example.com and www.example.com/index have any SEO impact?
- → SEO tags in Umbraco
- → Add dynamic divs around 6 image urls using jquery
- → ASP.NET Mvc 5 return View with seo friendly url
- → MVC SEO targeting Italy from a .uk.com domain
- → Using an object I never defined in JQuery
- → Pass json data from Google Maps to MVC controller with AJAX
- → Displaying Unique SEO code two times in the URL when change length 2 to 5
Ad