ASPX templates
Version 5.x > ASPX templates > Previous page URL & QueryString View modes: 
User avatar
Member
Member
Nesfuratu - 6/9/2011 8:03:05 PM
   
Previous page URL & QueryString
Hi,
I need to get the previous page's URL and QueryString. I would normally do the HttpContext.Current.Request.ReferrerUrl.PathAndQuery, but this will get me exactly what's on the address bar prior to going to the next page.

What I need is the Path and Query that Kentico reads in the background to generate the page. eg. The real path and query that Kentico reads is /Local-Store/News.aspx?StoreName=ninjastore. This will then translate to Ninja-Store/News.aspx. Because I have put in {StoreName}/News.aspx as an alias.

HttpContext.Current.Request.ReferrerUrl.PathAndQuery will only get me the path and query BEFORE the macro takes place, returning /Local-Store/News.aspx, which is useless to me because I'm really after the querystring StoreName.

Any ideas? Thanks.

John.

User avatar
Member
Member
kentico_michal - 6/13/2011 3:27:15 AM
   
RE:Previous page URL & QueryString
Hello John,

Could you please try to use the following expression?

HttpContext.Current.Request.Url

It should return the URL in format you want.

Best regards,
Michal Legen

User avatar
Member
Member
Nesfuratu - 6/13/2011 7:20:43 PM
   
RE:Previous page URL & QueryString
Hi Michal,

That would only get me the current page's URL. I need the URL of the previous page.

Thanks,
John.

User avatar
Member
Member
eric.rovtar - 6/15/2011 8:34:25 AM
   
RE:Previous page URL & QueryString
Since ASP is server-side, I don't think it has access to browser history. You would need to use JavaScript to do this:

var lastUrl = browser.history.previous;

User avatar
Member
Member
kentico_michal - 6/20/2011 1:40:16 AM
   
RE:Previous page URL & QueryString
Hello,

Sorry for confusion, I did not realize you need the previous Url. Regrettably, Kentico CMS does not provide any property that can be used to retrieve this information. So, you will need to use either the javascript as a client side alternative or get the information you need from the HttpContext.Current.Request.ReferrerUrl.PathAndQuery property.

Best regards,
Michal Legen