views:

23

answers:

1

Hello, I'm looking for a solution that allows me to get the parent page pathname from a partialView invoked. For example I have an Action baa and a controller boo so the javascript to obtain this will be window.location.pathname, and it returns /boo/baa.

The thing is that I use a partial view, so when I try to retrieve the pathname via the URL helper, what I obtain is the PartialView one, and what I need is the pathname for the action that invokes it. I want to do this because I want to show certain things of the partial view depending on the pathname of the parent view that invokes it. Is there a way to do this with ASP.NET MVC?

Thank you all in advance,

+1  A: 

You can access the RouteValues on the ViewContext on the page. This will contain the controller and action values as determined by the routing engine. You might want to consider making the determining information part of your model, however, as this exposes logic in the controller -- what the view does with this information, though, is completely up to it.

tvanfosson
I passed through this using context.request.urlReferrer from the partial view, this way I obtain exactly what I needed, anyway thanks very much for the reply
vikitor