简体   繁体   中英

Converting Persian Url Route to Persian Words on C#

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/%D8%AE%D8%A7%D9%86%D9%87/%D8%B5%D9%81%D8%AD%D9%87%20%D8%A7%D8%B5%D9%84%DB%8C 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 /%D8%AE%D8%A7%D9%86%D9%87/%D8%B5%D9%81%D8%AD%D9%87%20%D8%A7%D8%B5%D9%84%D part that this is تست/خانه So I need help to convert this /%D8%AE%D8%A7%D9%86%D9%87/%D8%B5%D9%81%D8%AD%D9%87%20%D8%A7%D8%B5%D9%84%D to this => تست/خانه in C# , MVC Core

这是 url 编码的,您需要对其进行解码。

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM