• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 567
  • Last Modified:

MVC tempdata issue - appending query string ID to URL

I have an MVC2 app which has a user control comprising of a dropdown (html.dropdownfor).  Its in the master page of the app.

If you click the dropdown it does a GET to select a customer details view

        <% using (Html.BeginForm("CustDetails", "Cust", FormMethod.Get))
           { %>
        <%= Html.DropDownList("id", Model.CustList)%>

If you select a customer from the dropdown and click go the customer details form is submitted.

This works fine as the query string is     /Cust/CustDetails?id=18

And it populated the customer details view.  

Now if I edit the customer details view this also works fine as the URL is this


However if I now click on the dropdown user control above and click go the URL is now like this


This only happens when I pass TempData to the view like this from the edit controller.

TempData["CustomerLevel"] = "Your level has been accepted.";

Is there anything with TempData I need to be aware of?
  • 2
1 Solution
I think your problem here is that the previous ID data (19 in your example) is being passed to the controller when you make the GET, so your querystring is screwed and your controller is lost.

ToString1Author Commented:
OK thanks. How can I fix it
I think your problem could be related to the positioning and building of the html forms inside your page.

You must check the html code of the pages to see why the parameter 19 is being sent when you make the get. If the two forms are clearly separated this shouldn't be happening, so probably there's some type of mess there.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now