开发者

How can I access the current URL when a view is rendered

How can I access the current url whe开发者_运维知识库n a view is rendered ?

That means, when i access http://mypage.com/index I have to show "index" in an html division in my page


If you're after action name

Untested but something along this lines:

<%= this.ViewContext.RouteValues["action"] %>

Maybe you'll have to access controller context (hence untested).

If you're after the actual URL

Manipulate controller action URL as you wish

<%= Url.Action("actionName", "controllerName") %>

If you're after URL on the client

Then Javascript is your friend:

window.location

has the value you need

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜