如何在渲染中获取当前URL

时间:2010-07-18 17:38:31

标签: c# asp.net-mvc-2

当我使用

获取渲染中的当前URL时
Request.Url.ToString()

它返回渲染的url而不是页面。有没有办法获取页面的当前网址?

1 个答案:

答案 0 :(得分:1)

使用ParentActionViewContext属性:

ParentActionViewContext.HttpContext.Request.Url.ToString()