London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Url property renders internal url

Vote:
 

I have a property on my page model :

		[Display(
			Name = "Link",
			Description = "",
			GroupName = TabNames.Content,
			Order = 30)]
		public virtual Url Link { get; set; }

This may be an external url, or it may link to a page. I want to render the href in the view, but for pages, i get the internal url out, and no url rewriting occurs on mvc to convert this to a rewritten url.

 

	<a href="@Model.Link.GetHref()"><img src="@Model.Image" alt="@Model.MainTitle" /></a>

    

how do i convert this to a nice url?

#63376
Nov 16, 2012 13:33
Vote:
 

You can use 

@Url.PageUrl(Model.Link.GetHref()) extension method

#63377
Nov 16, 2012 13:43
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.