crjunk
crjunk

Reputation: 969

Sitecore Layout File Name Returned

I'm trying to obtain the name of the web page in the address bar URL from a website developed with Sitecore.

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

Instead of returning what I expected to be "AboutUs.aspx", my code returns the Sitecore layout control file name: "BrowserFixedLaout.aspx".

I'm using the following code:

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

How do you achieve this when working with Sitecore?

Upvotes: 1

Views: 263

Answers (1)

Marek Musielak
Marek Musielak

Reputation: 27132

If you want to get the name of the page (item) in Sitecore, you can use

Sitecore.Context.Item.Name

if you want to get the /AboutUs.aspx only, you can use

HttpContext.Current.Request.Path

and take the part after last / only

Upvotes: 2

Related Questions