views:

183

answers:

2

How do you get the current path (url) from within an asp.net mvc view?

If there isn't a way to get it in the view, how can you get it in a controller so that it can be passed to the view?

EDIT

I don't want the protocol and host portion of the url.

A: 

Try:

 <%= Request.Url.AbsolutePath.ToString() %>
Damien
+1  A: 

This will return the url in the view for you:

'<%=Url.RouteUrl(ViewContext.RouteData.Values)%>
tuanvt