Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I have something like this:
@siteURL/[email protected]
This provides me a link something like : http://localhost/?p=1234
On selecting this url and placing in address bar it should redirect to the page content.
Ex: if 1234 is node id for home page, it should redirect to home page. How can I make this work like I expected?
Thanks.
A razor macro should do for you added to your master template.
@{Response.Redirect(Library.NodeById(Int.TryParse(Request.QueryString["p"])).url);}
NB untested and you will need to add all the usual errortrapping like ensure p is an integer and corresponds to a published node etc..
Actually didn't notice U7
Library.NodeById is deprecated...
so you can use
Umbraco.TypedContent(1234).Url
instead [https://our.umbraco.org/documentation/Reference/Templating/Mvc/querying]
Thanks Mike.
I have a doubt. I have a template where
this is inside guid tag.
The above provides me: sitename/1234.
When i copy paste this it shows me correct page but with url as sitename/1234. Is there a way where i can change 1234 the id to url of the page?
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
to fetch node url based on node id
Hi,
I have something like this:
@siteURL/[email protected]
This provides me a link something like : http://localhost/?p=1234
On selecting this url and placing in address bar it should redirect to the page content.
Ex: if 1234 is node id for home page, it should redirect to home page. How can I make this work like I expected?
Thanks.
A razor macro should do for you added to your master template.
@{Response.Redirect(Library.NodeById(Int.TryParse(Request.QueryString["p"])).url);}
NB untested and you will need to add all the usual errortrapping like ensure p is an integer and corresponds to a published node etc..
Actually didn't notice U7
Library.NodeById is deprecated...
so you can use
Umbraco.TypedContent(1234).Url
instead [https://our.umbraco.org/documentation/Reference/Templating/Mvc/querying]
Thanks Mike.
I have a doubt. I have a template where
this is inside guid tag.
The above provides me: sitename/1234.
When i copy paste this it shows me correct page but with url as sitename/1234. Is there a way where i can change 1234 the id to url of the page?
Thanks.
is working on a reply...