MVC tempdata issue - appending query string ID to URL

Posted on 2011-05-13
Last Modified: 2012-05-11
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?
Question by:ToString1
    LVL 19

    Expert Comment

    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.


    Author Comment

    OK thanks. How can I fix it
    LVL 19

    Accepted Solution

    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.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now