In my MVC3 app, if i type in a query string value in the url and hit enter, I can get the value i typed:
localhost:34556/?db=test
My default action which will fire:
public ActionResult Index(string db)
The variable db has "test" in it.
Now, i need to submit a form and read the query string value, but when I submit the form via jQuery:
$('#btnLogOn').click(function(e) {
e.preventDefault();
document.forms[0].submit();
});
And the following is the form i'm sending:
@using (Html.BeginForm("LogIn", "Home", new { id="form1" }, FormMethod.Post))
Heres the action:
[HttpPost]
public ActionResult LogIn(LogOnModel logOnModel, string db)
{
string dbName= Request.QueryString["db"];
}
The variable dbName is null because Request.QueryString["db"] is null, so is the variable db being passed in and i dont know why. Can someone help me get a query string variable after a form is submitted? Thanks