Home > Mobile >  Converting Persian Url Route to Persian Words on C#
Converting Persian Url Route to Persian Words on C#

Time:11-05

I made my routes to Persian , cause of that my Url route in StartUp config is like

endpoints.MapControllerRoute(
            name: "HomeController",
            defaults: new { controller = "Home", action = "Test" },
            pattern: $@"تست/خانه");

And it turns into this https://localhost:44377/خانه/صفحه اصلی in Browser address bar and also when I try to get current request path in controller with Request.HttpContext.Request.Path, it gives me the /خانه/صفحه اصل%D part that this is تست/خانه So I need help to convert this /خانه/صفحه اصل%D to this => تست/خانه in C# , MVC Core

CodePudding user response:

This is url encoded and you need to decode it.

System.Web.HttpUtility.UrlDecode(Request.HttpContext.Request.Path);
  • Related