Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Query String issue when it contains Arabic text

I am trying to get query string from url With this code:

this.site_query = Request.Url.Query;

When I have get url:

http://localhost:1751/ar/search?q=سيارة

It gives me blow output in code:

http://localhost:1751/ar/Search?q=%D8%B3%D9%8A%D8%A7%D8%B1%D8%A9&Location=%D8%A3%D8%A8%D9%87%D8%A7,Abha

But I need Arabic text that I send in query string. When query string contains text in English then in c# it is correct.

like image 517
Coder Avatar asked Nov 30 '25 05:11

Coder


1 Answers

There is nothing wrong with the second URL you have shown in your answer, it's just being URL encoded due to the limitations of what characters are allowed in URLs.

If you wish to get parts of the query string in code, you can use code like this:

var query = Request.QueryString["q"];

Additionally, if you are building your URLs in code, you should always URL encode and values that may contain non standard characters:

var urlEncodedValue = HttpUtility.UrlEncode(someValue);
like image 134
DavidG Avatar answered Dec 01 '25 17:12

DavidG



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!