1
我有一个移动应用程序,有几个文件夹。这些文件夹作为变量,我将增加参数:从URL手机,重定向将参数%20添加到参数
//Get the 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];
}
}
我以后的道路我根据手机类型重定向:
if (Request.UserAgent.ToUpper().Contains("BLACKBERRY"))
{
//Now we check the 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 are 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);
}
}
的问题是,它location
将在前面添加“%20”。这不会发生,如果我在台式机上测试它,只能在手机上测试。
这是怎么发生的?我怎样才能防止这一点?
啊。愚蠢的错误。虽然有好点子! –