简体   繁体   English

ASP.net没有捕获QueryString

[英]ASP.net not catching QueryString

I have created a ASP.net application,where i change the language base on its query string. 我创建了一个ASP.net应用程序,在其中我根据查询字符串更改了语言。 I have two servers both are https ,but one is redirected by netscaler 我有两个服务器都是https,但是其中一个由netscaler重定向

https://testMyLiveCode.com
https://myNetscalerServer.com/testapply-aU4uC6Q9dU94nHzVZA6zdtaQE433Xa2a/?

For eg 例如

https://testMyLiveCode.com/?ln=en https://testMyLiveCode.com/?ln=en

This is my asp.net code 这是我的asp.net代码

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服务器完美配合

https://testMyLiveCode.com/?ln=en https://testMyLiveCode.com/?ln=en

But this doesnt work with my netscaler url 但这不适用于我的netscaler网址

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 在我将查询字符串添加到它之后,它不起作用https://myNetscalerServer.com/testapply-aU4uC6Q9dU94nHzVZA6zdtaQE433Xa2a/??ln=en

Can anyone help why this is not working as the url already has a ? 任何人都可以帮忙,为什么它不起作用,因为该URL已经有一个? 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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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