SaaS CMS has officially launched! Learn more now.

Rendering Episerver.Url with mailto, results in garbage characters

Vote:
 

Pretty straightforward, I ripped off the Alloy MVC demo and either one of these

@Html.UrlLink(new EPiServer.Url("mailto:adress@host.se"))
<a href="@Url.ContentUrl(new EPiServer.Url("mailto:adress@host.se"))">Send email</a>

Renders an anchor tag with href="mailto::25//adress@host.se:25". If I try anything other than mailto, for instance

@Html.UrlLink(new EPiServer.Url("mailltoo:adress@host.se"))

Then it renders correctly. Sadly my browser does not understand what "mailltoo" means. Email adresses in EPiServer.SpecializedProperties.LinkItems work fine, but all I have is this Url. How do I wrangle a clean href string out of it, regardless of what the target might be?

#82547
Mar 14, 2014 11:23
Vote:
 

Hi Kjell

Same issue happened to me, do you have any solution for this issue?

#88706
Jul 26, 2014 4:51
Vote:
 

If your email address is a string property in your model, you can just use:

@Html.PropertyFor(m => m.CurrentPage.Email)



#88725
Jul 28, 2014 13:30
Vote:
 

Hey,

I have the following definition:

        [Display(
            GroupName = SystemTabNames.Content,
            Order = 30)]
        [BackingType(typeof(PropertyUrl))]
        public virtual Url Info { get; set; }

And the following rendering:

            

@Model.CurrentBlock.Info = mailto:info@mogul.com, ie.

The version of EPi is 7.7.1.0.

#88726
Jul 28, 2014 13:47
Vote:
 

Hi Mari

If I set this property as string and user wants to set this as internal page link later, it's not that user fridenly to the end user.

#88727
Jul 28, 2014 15:00
Vote:
 

Hi Marija

If I render the href without using @Url.ContentUrl helper method, it's all working fine even without having BackingType attribute. Howerver if the property value is changed to internal link, the href value is not displaying as a friendly url instead it displays the episerver internal link e.g. /link/xxxxxxx.

I am not too sure if the episerver internal link will affect the SEO, that's why I prefer to use Url.ContentUrl helper to generate the EPiServer.Url link no matter what type of the url it is. 

#88729
Jul 28, 2014 15:15
Vote:
 

Hello Guys,

I am experiencing the same issue, did you manage to circumvent this issue without creating a new block?

Cheers,

#113869
Nov 28, 2014 20:13
Vote:
 

Late reply, but still relevant. I was faced with the same problem. My solution was to get the url differently if it was a mailto.

var href = Model.MyUrl.Scheme == "mailto" ? Model.MyUrl.ToString() : Url.ContentUrl(Model.MyUrl);

You can create an extension method that returns the processed Url

public static string Url(this HtmlHelper helper, Url url)
{
    if (url == null)
        return null;

    return url.Scheme == "mailto" ? url.ToString() : UrlExtensions.ContentUrl(null, url);
}

Or you can create an extension method that returns an anchor with the correct url, it's up to you :)

All the best,
Micke

#114699
Dec 18, 2014 14:35
Vote:
 

I know this is an old post...but, I'm having the same issue. Has anyone reported this as a bug? Is EPiServer planing on fixing it?

#134528
Sep 15, 2015 16:54
Vote:
 

For you who reads this.
If you change to use Url.ContentUrl instead it works with both email address and internal links

#173827
Jan 10, 2017 15:54
* 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.