我怎样查询字符串发送URL作为查询字符串 [英] How do I send a URL with Query Strings as a Query String

查看:175
本文介绍了我怎样查询字符串发送URL作为查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做的,从一个网页到另一个重定向和从第二页的另一个重定向到三分之一。我已经从未在第二页上使用,但必须被转移到第三页中的第一页imformation。是否有可能与它的查询字符串作为查询字符串的第三页的URL发送到第二页。这里有一个例子:

I am doing a redirect from one page to another and another redirect from the second page to a third. I have imformation from the first page which is not used on the second page but must be transfered to the third page. Is it possible to send the URL of the third page with its Query Strings as a Query String to the second page. Here's an example:

Response.Redirect("MyURL1?redi=MyURL2?name=me&ID=123");



我的问题是,URL发送作为查询字符串有两个查询字符串变量,所以怎么会系统知道后有什么&放大器;是第二个URL的第二可变,而不是第一个URL的一个第二变量?谢谢你。

My problem is that the URL being sent as a Query String has two Query String variables, so how will the system know that what's after the & is the second variable of the second URL and not a second variable of the first URL? Thank you.

推荐答案

您必须编码,你通过在你的重定向URL参数的URL。 ?MyURL1 REDI =?像这样

You must encode the url that you pass as a parameter in your redirect URL. Like this:

MyURL = "MyURL1?redi=" + Server.UrlEncode("MyURL2?name=me&ID=123");

这将创建一个正确的URL没有双和'和;'字符'?':

This will create a correct url without the double '?' and '&' characters:

MyURL1?redi=MyURL2%3fname%3dme%26ID%3d123

请参阅MSDN: HttpServerUtility.UrlEncode方法

要从这个编码网址必须使用提取您重定向URL HttpServerUtility.UrlDecode 来把它变成一个正确的网址一次。

To extract your redirect url from this encoded url you must use HttpServerUtility.UrlDecode to turn it into a correct url again.

这篇关于我怎样查询字符串发送URL作为查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆