Url.Action is keeping old parameters from a previous requesthttp://forums.asp.net/t/1770574.aspx/1?Url+Action+is+keeping+old+parameters+from+a+previous+requestTue, 21 Feb 2012 18:18:25 -050017705744836748http://forums.asp.net/p/1770574/4836748.aspx/1?Url+Action+is+keeping+old+parameters+from+a+previous+requestUrl.Action is keeping old parameters from a previous request <p>There are many ways of navigating to the search page (or more technically the search controller's index view) on my site. One of the ways involves loading a saved search from a previous session, which redirects the user to /Search/Index/{ID}</p> <p>When the user is done and wants to start a new search, they normally click on the search link in the website's navigation bar in order to reset the page:</p> <pre class="prettyprint">&lt;a href=&quot;@Url.Action(&quot;Index&quot;, &quot;Search&quot;)&quot;&gt;Search&lt;/a&gt;</pre> <p>However, rather than being brought to /Search, the Url.Action link instead points to /Search/Index/{ID}. As a result, the user is stuck in a loop. It doesn't take very long for most people to realize that they can go to another page/controller/view and then come back, but that's an undesirable workaround at best.</p> <p>How do I fix this?</p> 2012-02-16T22:02:49-05:004837022http://forums.asp.net/p/1770574/4837022.aspx/1?Re+Url+Action+is+keeping+old+parameters+from+a+previous+requestRe: Url.Action is keeping old parameters from a previous request <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Faize</h4> It doesn't take very long for most people to realize that they can go to another page/controller/view and then come back</blockquote> <p></p> <p>And how this solve the problem? The action link on other page is not the same?</p> 2012-02-17T05:01:47-05:004837946http://forums.asp.net/p/1770574/4837946.aspx/1?Re+Url+Action+is+keeping+old+parameters+from+a+previous+requestRe: Url.Action is keeping old parameters from a previous request <p>The action <strong>link</strong> on other pages is not the same indeed, even though the navigation bar lives in a shared Razor layout page and the <strong>code</strong> is therefore identical.</p> 2012-02-17T16:34:18-05:004838353http://forums.asp.net/p/1770574/4838353.aspx/1?Re+Url+Action+is+keeping+old+parameters+from+a+previous+requestRe: Url.Action is keeping old parameters from a previous request <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Faize</h4> The action <strong>link</strong> on other pages is not the same indeed</blockquote> <p></p> <p>How it differs? Tell us the 2 html's<br> And do you have areas?</p> 2012-02-18T01:22:28-05:004841607http://forums.asp.net/p/1770574/4841607.aspx/1?Re+Url+Action+is+keeping+old+parameters+from+a+previous+requestRe: Url.Action is keeping old parameters from a previous request <p>The HTML on all pages is exactly what's shown in my first post, because it lives on a shared Razor layout page.</p> 2012-02-20T16:39:51-05:004841808http://forums.asp.net/p/1770574/4841808.aspx/1?Re+Url+Action+is+keeping+old+parameters+from+a+previous+requestRe: Url.Action is keeping old parameters from a previous request <p></p> <blockquote><span class="icon-blockquote"></span> <h4>Faize</h4> The HTML on all pages is exactly what's shown in my first post, because it lives on a shared Razor layout page.</blockquote> <p></p> <p>I want the GENERATED html. ( only the</p> <p>a) the url of the page and the&nbsp; link that is clicked and works</p> <p>b) the url of the page and the link that is clicked and does not work, </p> 2012-02-20T19:57:58-05:004843676http://forums.asp.net/p/1770574/4843676.aspx/1?Re+Url+Action+is+keeping+old+parameters+from+a+previous+requestRe: Url.Action is keeping old parameters from a previous request <p>The ASP.NET MVC framework retains ambient route values. Implement your search by doing a GET, not a post (which you should do anyway) and the search parameters will be query strings. That way you can bookmark the search. Clicking on the search link clears the query strings. See</p> <p><a href="http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/getting-started-with-mvc3-part6-cs">http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/getting-started-with-mvc3-part6-cs</a></p> <p>You need to use the overload that specifies GET.</p> <pre class="prettyprint">@using (Html.BeginForm(&quot;SearchIndex&quot;,&quot;Movies&quot;,FormMethod.Get))</pre> <p></p> 2012-02-21T18:18:25-05:00