This project is read-only.

Url.Action changes when I Hit Back button in browser, Orchard

Topics: General
Nov 16, 2011 at 6:47 PM

Hi I am working on an app in orchard:

This is the scenario:

In one of my views in MyCompany.Comments I have the following:

<p> <a href='@Url.Action("Create", "Users", new {area = "MyCompany.Users"} )'> Add New User</a></p>

When i load the page for the first time and i click on the link it takes me to the right page but when i click the back button on the browser then for the Add New User link displays the create action method in MyCompany.Comments module.

Any thoughts on how to get around it?

Thanks in Advance. 

Nov 16, 2011 at 10:51 PM

That is simply not possible. Something else must be going on. When you do view source before and after, do you see a difference?

Nov 16, 2011 at 11:29 PM

Yes i do see a difference...

Thats exactly what i said...

Nov 17, 2011 at 12:04 AM

You did not say what the difference in html source was.

Nov 17, 2011 at 12:57 PM

I wouldn't say it's not possible - I've seen odd things going on with MVC areas and action links; for instance occasionally in the Admin menu, and very recently in the Alias module, although this particular situation does sound a bit strange. What was happening in Alias was that the area was getting stripped out of the RouteValueDictionary (and this was happening within compiled MVC code so I couldn't see exactly why). In that circumstance then the area would indeed get assumed to be the current area of the view, in this case MyCompany.Comments.

Nov 17, 2011 at 1:00 PM

Just one idea of something to try (and probably inconsequential) but try capitalising the a in Area.

Nov 18, 2011 at 5:38 PM

Sorry i didnt answer you right away.. I cleaned and recompiled my project and it worked.. Thanks for your help

Nov 18, 2011 at 10:38 PM

randompete.. thats exactly what is going on with me now again...

I cannot get around it for some reason...


<div id="newEmail">
<p> <a href="@Url.Action("Create", "Clients", new { Area = "myproject.Dashboard", Controller = "Clients", Action = "Create" })"> Add New Email</a></p>

<div id="workitemlist">
<p> <a href="@Url.Action("Index", "WorkItem", new { Area = "myproject.Dashboard", Controller = "WorkItem"})"> Back to WorkItems</a></p>

Before: this is when the page first loads.. so it looks fine.

<div id="newEmail">
<p> <a href="/OrchardLocal/Clients/New"> Add New Email</a></p>

<div id="workitemlist">
<p> <a href="/OrchardLocal/WorkItems"> Back to WorkItems</a></p>

After: when i hit the back button this comes back.. now its going to a complete diferent area

<div >
<p> <a href='/OrchardLocal/myproject.Users/FirmUsers/Create'> Add New Email</a></p>

its annoying because i cant commit until i can get around this issue..

Nov 18, 2011 at 10:41 PM

I stand corrected. Can you do a network trace from your browser's dev tools and see if you see a difference in request headers between the two requests. Also, check if one or both came from the cache (using the response status).

Nov 18, 2011 at 10:57 PM
Edited Nov 18, 2011 at 11:00 PM

I just tried it in FireFox and It worked fine..

I usually use IE for developement because I use firefox for Searching and other stuff.

Do you know of a way of solving this problem like: cleaning the cache in windows explorer using Visual Studio I guess?


Even when i clean the cache manually the problem still persists..

Nov 18, 2011 at 11:15 PM

So I cleared the cache in WindowsExplorer 9. the problem was still there

then i did it using fiddler..

then it worked fine..