I have created a ASP.net application,where i change the language base on its query string. I have two servers both are https ,but one is redirected by netscaler
https://testMyLiveCode.com
https://myNetscalerServer.com/testapply-aU4uC6Q9dU94nHzVZA6zdtaQE433Xa2a/?
For eg
https://testMyLiveCode.com/?ln=en
This is my asp.net code
string strNewLanguage = Request.QueryString["ln"].ToLower();
SessionHelper.Language = strNewLanguage ;
string strNewURL = Request.RawUrl.ToLower().Replace("ln=" + Request.QueryString["ln"], "");
Response.Redirect(strNewURL);
What i actually do is that change the language depending on querystring and change the querystring and redirects
THis works perfectly with my https Server
https://testMyLiveCode.com/?ln=en
But this doesnt work with my netscaler url
https://myNetscalerServer.com/testapply-aU4uC6Q9dU94nHzVZA6zdtaQE433Xa2a/?
This is my url
And after i added the querystring to it,it does not work https://myNetscalerServer.com/testapply-aU4uC6Q9dU94nHzVZA6zdtaQE433Xa2a/??ln=en
Can anyone help why this is not working as the url already has a ? in it??? Thanks for any help
My suggestion is to change the string which contains '?', it you can't then below instruction and code might help you I am writing below code based on language array, you need to modify this based on your requirement, Hopefully this will help.It's bad code you have to modify this to make this good
string[] obj = new string[5] {"hi","en","ar","or","xy" };
string urlString = Request.RawUrl.ToLower();
int location = 0;
for (int i = 0; i < obj.Length; i++)
{
if (urlString.Contains("=" + obj[i]))
{
location = i;
break;
}
}
string strNewURL = Request.RawUrl.ToLower().Replace("ln=" + obj[location], "");
Response.Redirect(strNewURL);
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.