I have this simple javascript code:
var value = "I love programming";
window.location="Controller/Action/"+value;
In controller page, I have this:
public ActionResult(string value) {
// do something
}
The problem is value parameter from controller. This is always null.
Why ?
Is the parameter type is restricted to int? (without using ajax)
I can send an int to controller and it process the information correctly. But not string.
You may need to set up a route in global.asax to handle the string parameter, i.e:
this is all top of the head stuff, so it may not happen for you.
[update 1] as you say in the comment below, changing the parameter name from value=>id should resolve the problem without recourse to addtional routes.
[update 2] – you could also, as per sandeep’s comment, opt for the name-value pair on the url, i.e. window.location=”Controller/Action?value=”+yourValue