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 all,
I'm looking at creating a redirect page, so if you click on the page it redirects you to an external URL.
I've created a doc type with a template called "Page Redirect" with a field called Link Target inside my template I have the following code;
@inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.PageRedirect> @using ContentModels = Umbraco.Web.PublishedModels; @{ Layout = "master.cshtml"; string linkUrl = ""; if(Model.HasValue("linkTarget")) { var linkItem = Model.linkTarget.First; linkUrl = linkItem.link; } if(!String.IsNullOrEmpty(linkUrl)) { Response.Redirect(linkUrl); } }
But I'm getting the following error;
CS1061: 'PageRedirect' does not contain a definition for 'linkTarget' and no accessible extension method 'linkTarget' accepting a first argument of type 'PageRedirect' could be found (are you missing a using directive or an assembly reference?)
Any advice to get this working? :)
Hi Matt,
I think you need to change var linkItem = Model.linkTarget.First;
To
var linkItem = Model.LinkTarget.First;
Make link capital and try.
Hi Shaishav,
Thanks for reply;
This is what I get now;
CS0815: Cannot assign method group to an implicitly-typed variable
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Create a redirect page
Hi all,
I'm looking at creating a redirect page, so if you click on the page it redirects you to an external URL.
I've created a doc type with a template called "Page Redirect" with a field called Link Target inside my template I have the following code;
But I'm getting the following error;
Any advice to get this working? :)
Hi Matt,
I think you need to change var linkItem = Model.linkTarget.First;
To
Make link capital and try.
Hi Shaishav,
Thanks for reply;
This is what I get now;
CS0815: Cannot assign method group to an implicitly-typed variable
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.