Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Pedro Adão 43 posts 80 karma points
    Mar 09, 2017 @ 14:43
    Pedro Adão
    0

    Umbraco Core how to use urlReplacing

    Hi,

    We can define urlReplacing in /config/umbracoSettings.config under RequestHandler

    <char org="à">a</char>
    <char org="á">a</char>
    

    Is this available in Umbraco.Core? Something like this:

    var myCustomUrl = "this is a unsafe url àá that needs char replace %+* :)";
    
    var safeUrl = Umbraco.Core.something.UrlReplacing(myCustomUrl);
    

    Thank you, Adão

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Mar 09, 2017 @ 16:15
    Alex Skrypnyk
    102

    Hi Pedro

    Just use ToUrlSegment() extention method like this:

    myCustomUrl.ToUrlSegment()
    

    It will return safe and great url segment the same as Umbraco do it. So your code will be:

    var myCustomUrl = "this is a unsafe url àá that needs char replace %+* :)";
    
    var safeUrl = myCustomUrl.ToUrlSegment();
    

    Thanks,

    Alex

  • Pedro Adão 43 posts 80 karma points
    Mar 10, 2017 @ 10:32
    Pedro Adão
    0

    Thank you @Alex Skrypnyk ! =)

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Mar 10, 2017 @ 10:33
    Alex Skrypnyk
    0

    You are welcome!!!

    Have a nice day!

Please Sign in or register to post replies

Write your reply to:

Draft