c# - Mobile phone, Redirect adding %20 to parameter -


i have mobile app few folders. these folders used variables add parameters:

        //get url         string url = httpcontext.current.request.url.absolutepath;          //location         string location = "";          //check if string contains /         if (url.contains('/'))         {             //get location             string[] words = url.split('/');              //set location              location = words[1];              //now check if string contains ?             if (location.contains('?'))             {                 //remove ?                 string[] removeq = location.split('?');                  //reset location                 location = removeq[0];             }          } 

after path url have redirect depending on phone type:

        if (request.useragent.toupper().contains("blackberry"))         {             //now check version             if (double.parse(request.browser.version) <= 5)             {                 response.redirect("http://mywebsite.com/default.aspx?location= " + location);             }             else if (double.parse(request.browser.version) >= 6)             {                 response.redirect("http://mywebsite.com/default.aspx?location= " + location);             }             else             {                 response.redirect("http://mywebsite.com/default.aspx?location= " + location);             }          }         else if (request.useragent.toupper().contains("htc")) //htc phones cannot handle jquery mobile         {             response.redirect("http://mywebsite.com/default.aspx?location= " + location);         }         else if (request.useragent.toupper().contains("android")) //certain androids out of date         {             if (double.parse(request.browser.version) > 2)             {                 response.redirect("http://mywebsite.com/default.aspx?location= " + location);             }             else             {                 response.redirect("http://mywebsite.com/default.aspx?location= " + location);             }          }         else         {             response.redirect("http://mywebsite.com/default.aspx?location= " + location);         }     } 

the problem location have "%20" added front. not happen if test on desktop, on phones.

why happening? how can prevent this?

remove spaces end of string literals e.g. change:

"http://mywebsite.com/default.aspx?location= " + location 

to

"http://mywebsite.com/default.aspx?location=" + location 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -