In my MVC3 application, if I type the value of the query string in url and press enter, I can get the value entered:
localhost:34556/?db=test
My default action that will fire:
public ActionResult Index(string db)
There is a βtestβ in the db variable.
Now I need to submit the form and read the value of the query string, but when I submit the form via jQuery:
$('#btnLogOn').click(function(e) { e.preventDefault(); document.forms[0].submit(); });
And the following form that I submit:
@using (Html.BeginForm("LogIn", "Home", new { id="form1" }, FormMethod.Post))
Here is the action:
[HttpPost] public ActionResult LogIn(LogOnModel logOnModel, string db) { string dbName= Request.QueryString["db"]; }
The value of the dbName variable is null because Request.QueryString ["db"] is null, so the db variable is passed, and I donβt know why. Can someone help me get the query string variable after submitting the form? Thanks
source share