c# - Get query string values when submitting a form...MVC3 -


In my MVC 3 app, if I type a query string value in the URL and the entry is killed, I can get I typed:

  localhost: 34556? DB = test   

My default action will be fire:

  public action index (string db)   

variable There is a "test" in DB.

Now, I need to submit the form and read the query string value, but when I submit the form via jQuery.

  (function (e $ ('# btnLogOn')) {e.preventDefault (); document.forms [0] .submit ();});   

and the following I am sending:

  @using (HTML.BeginForm ("Login", "Home", New {id = "Form1" "}, FormMethod.Post))   

Action here:

  [HttpPost] public ActionResult login (logOnModel logOnModel, string database) {string dbName = Request .QueryString ["db"]; }   

variable dbName is zero because the request.QueryString ["db"] is zero, therefore variable db is being passed and I do not know why after submitting a form what is Can query string get variable? Thank you

You can do something like

Controllers: < Pre> [HTTPGet] Public Action Result Login (string dbnm) {logonview model love = new logonview model (); // Returning Voododl Here Return here (Love); } [HTTPOst] Public Action Result Login (LogoneView Model Limum, String DBNM) {if (ModelState.IsValid) {// You can refer to DBN name by typing DBN name (i.e.) string test = dbn name here Are; // Which one you want here is probably a redirect? } See Return (Love); }

view module:

  public class logonview model {// whatever assets you have}}   

edited Do: It was decided for your requirement.

Comments