【问题标题】:Sitecore Layout File Name Returned返回的 Sitecore 布局文件名
【发布时间】:2012-12-20 04:07:25
【问题描述】:

我正在尝试从使用 Sitecore 开发的网站获取地址栏 URL 中的网页名称。

http://localhost:52543/About/AboutUs.aspx

我的代码没有返回我预期的“AboutUs.aspx”,而是返回 Sitecore 布局控制文件名:“BrowserFixedLaout.aspx”。

我正在使用以下代码:

Dim test As String = System.IO.Path.GetFileName(Request.Url.ToString())

在使用 Sitecore 时,您如何实现这一目标?

【问题讨论】:

    标签: asp.net vb.net sitecore


    【解决方案1】:

    如果想在 Sitecore 中获取页面(item)的名称,可以使用

    Sitecore.Context.Item.Name
    

    如果你只想获取 /AboutUs.aspx,你可以使用

    HttpContext.Current.Request.Path
    

    在最后一个/只参加之后的部分

    【讨论】:

    • 或 HttpContext.Current.Request.RawUrl 如果您还需要查询字符串。
    • HttpContext.Current.Request.Path 仍然返回布局名称。最终使用了 Sitecore.Context.Item.Name。谢谢!
    猜你喜欢
    • 2013-06-21
    • 1970-01-01
    • 1970-01-01
    • 2017-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-14
    • 1970-01-01
    相关资源
    最近更新 更多