Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > CMS.CMSHelper.CMSContext.CurrentAliasPath Doesn't Return Correct Path View modes: 
User avatar
Member
Member
scott_hancock-urmc.rochester - 3/11/2011 7:44:28 AM
   
CMS.CMSHelper.CMSContext.CurrentAliasPath Doesn't Return Correct Path
I'm developing a webpart and I'm trying to get the URL of the current page. I tried to use CurrentAliasPath but what it returns is not correct. I'm running it on Visual Studio's built-in web server.

The url of the page is:
http://localhost:52419/xyz/encyclopedia/listalldocuments.aspx

CurrentAliasPath returns:
/Encyclopedia/ListAllDocuments

RawURL returns:
/xyz/encyclopedia/listalldocuments.aspx

Why does CurrentAliasPath drop the xyz?
Why does it drop the aspx from ListAllDocuments? There is no alias ListAllDocuments. Navigating to http://localhost:52419/xyz/encyclopedia/listalldocuments returns a 404 error.

Thanks,
Scott

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 3/11/2011 2:08:29 PM
   
RE:CMS.CMSHelper.CMSContext.CurrentAliasPath Doesn't Return Correct Path
Hi,

Alias path is not the URL - therefore it is missing the extension. Also, "xyz" is a document in the tree structure or is it a virtual directory/application path?

Alias path returns value from the root of the web site - so if xyz is a virtual directory it is not the document's alias path (since you can move the site under other virtual directory).

If you want to check the URL, you need to compose it from the alias path:

"http://localhost:52419/xyz" + CMS.CMSHelper.CMSContext.CurrentAliasPath + ".aspx".

Or you can use one of the methods from URLHelper class such as GetAbsoluteURL().

Best regards,
Juraj Ondrus