Oralet
Oralet

Reputation: 347

C# ASP.NET Foreign Characters(ü) Ampersand Confusion

I am developing a simple website and I need to use Turkish characters (ç,ş,ğ,ı,ü) in usernames and other fields. When executing the following statement,

Response.Redirect("View2.aspx?ApplicantName=" + applicantname);

It cannot get the applicant's name when the applicant name contains "ü". I suspect it is because "ü" has ampersand (&) in its representation which is ü.

So what do I need to do to fix it?

Upvotes: 2

Views: 966

Answers (2)

zer0w1dthspace
zer0w1dthspace

Reputation: 1052

Add this line (or change if it exist) to your web.config file's system.web section.

  <globalization culture="tr-TR" uiCulture="tr-TR" fileEncoding="iso-8859-9" requestEncoding="iso-8859-9" responseEncoding="iso-8859-9" />

Upvotes: 2

Brian Webster
Brian Webster

Reputation: 30865

All you need is the proper URLEncoding

Response.Redirect("View2.aspx?ApplicantName=" + Server.UrlEncode(applicantname));

Or, if you are using Unicode:

Response.Redirect("View2.aspx?ApplicantName=" + HttpUtility.UrlEncode(applicantname, System.Text.Encoding.GetEncoding("ISO-8859-1")));

Don't forget to URLDecode on the other end.

References

Upvotes: 2

Related Questions