Paul77M Paul77M - 1 year ago 104
C# Question

MVC Issue with Model appearing in Query String

I have built an MVC 5 Application that dynamically loads child applications from DLLs. Everything works as expected but somewhere along the way, I noticed that my Models started to appear to be represented in the Query Strings despite using Post.

They are appearing like this:


While I would expect them to appear like this:


Unfortunately this had to be put to the side for another project for some time and I am just getting back to it. I know before I put it down, I attempted to rebuild a good portion of the application trying to tack the issue down and did not come across the cause of it.

Because my routes are dynamically generated, I cannot show a snippet of code, but here are the Route URL values (in order at runtime):











My Controller Action looks like this:

public ActionResult LookupUser(UserLookup LookupModel, FormCollection FormData)
UserLookup UL = null;
return View(UL);

The form in the View looks like this:

@using (Html.BeginForm("LookupUser", Application.ApplicationPrefix, new { PageModel = Model }, FormMethod.Post, new { id = "LookupArea", @class = (Model.Memberships.Count > 0 ? "LoadedWithContent" : ""), role = "form" }))
<input type="submit" id="Submit_btn" value="Lookup" />

On top of numerous other attempts, I have tried taking out the default routes, moved "{controller}/{action}/{id}" to the end, taking out extraneous routes, removed ", FormCollection FormData" and plenty of things I have long since forgotten. The URL that comes into Application_BeginRequest in Global.asax.cs has the model on it.

I have also rewritten or extended significant portions of the MVC Framework to enable the dynamic content from DLLs, security checking or error redirection, so it could have to do with some portion of that or it could be something simple like a form parameter or the route order (even though I attempted to check that).

Any guidance on where to narrow down the scope of where to look or insight as to what can cause this would be appreciated.

Answer Source

Stephen's recommendation above corrected my issue (which was mostly just seeing the trees through the forest).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download