2 Languages Website by ASP.NET

This is a simple trick to make a 2 Languages Website. You have to get to real path then put the querystring after that path. Let’s see this example.

Put this code at the Page_Load in the MasterPage File or any page you want.

string[] allKey = Request.QueryString.AllKeys;
string qString = “?”;
for (int i = 0; i < allKey.Length; i++) { if (allKey[i].ToLower() != "lang") { { qString += allKey[i] + "=" + Request.QueryString[allKey[i]] + "&"; } } } hrefThai.HRef = Request.Url.AbsoluteUri.Split('?')[0] + qString + "lang=th"; hrefEng.HRef = Request.Url.AbsoluteUri.Split('?')[0] + qString + "lang=en";