I have three values which I have to pass as parameters for e.g., strID
, strName
and strDate
.
我有三个值必须作为参数传递,例如strID、strName和strDate。
I want to redirect these three parameters to another page in Response.Redirect()
.Can anybody provide me with the correct querystring?
我想将这三个参数重定向到Response.Redirect()中的另一个页面。谁能给我提供正确的查询字符串吗?
6 个解决方案
#1
77
Query_string
(Following is the text of the linked section of the Wikipedia entry.)
(以下是*条目的链接部分。)
Structure
A typical URL containing a query string is as follows:
包含查询字符串的典型URL如下:
http://server/path/program?query_string
http://server/path/program?query_string
When a server receives a request for such a page, it runs a program (if configured to do so), passing the query_string unchanged to the program. The question mark is used as a separator and is not part of the query string.
当服务器收到这样一个页面的请求时,它会运行一个程序(如果配置为这样做的话),并将query_string不加修改地传递给程序。问号用作分隔符,而不是查询字符串的一部分。
A link in a web page may have a URL that contains a query string, however, HTML defines three ways a web browser can generate the query string:
web页面中的链接可能具有包含查询字符串的URL,但是HTML定义了web浏览器生成查询字符串的三种方式:
- a web form via the ... element
- 一个通过…元素
- a server-side image map via the ismap attribute on the element with a construction
- 通过元素上的ismap属性构建的服务器端图像映射
- an indexed search via the now deprecated element
- 通过现在已弃用的元素进行索引搜索
Web forms
The main use of query strings is to contain the content of an HTML form, also known as web form. In particular, when a form containing the fields field1, field2, field3 is submitted, the content of the fields is encoded as a query string as follows:
查询字符串的主要用途是包含HTML表单(也称为web表单)的内容。特别是,当提交包含字段field1、field2、field3的表单时,字段的内容被编码为如下所示的查询字符串:
field1=value1&field2=value2&field3=value3...
field1 = value1&field2 = value2&field3 = value3……
- The query string is composed of a series of field-value pairs.
- 查询字符串由一系列字段值对组成。
- Within each pair, the field name and value are separated by an equals sign. The equals sign may be omitted if the value is an empty string.
- 在每对中,字段名和值用等号表示。如果值是空字符串,则可以省略等号。
- The series of pairs is separated by the ampersand, '&' (or semicolon, ';' for URLs embedded in HTML and not generated by a ...; see below). While there is no definitive standard, most web frameworks allow multiple values to be associated with a single field:
- 这一系列的对是由ampersand, '&'(或分号,';',' ',' ',' ',' ' . ' ',' ',' ',' ' ' ',' ' ' ' ' ' ' ',' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '见下文)。虽然没有确定的标准,但是大多数web框架允许多个值与单个字段关联:
field1=value1&field1=value2&field1=value3...
field1 = value1&field1 = value2&field1 = value3……
For each field of the form, the query string contains a pair field=value. Web forms may include fields that are not visible to the user; these fields are included in the query string when the form is submitted
对于表单的每个字段,查询字符串包含一对字段=值。Web表单可以包含用户不可见的字段;当表单提交时,这些字段包含在查询字符串中。
This convention is a W3C recommendation. W3C recommends that all web servers support semicolon separators in addition to ampersand separators[6] to allow application/x-www-form-urlencoded query strings in URLs within HTML documents without having to entity escape ampersands.
此约定是W3C推荐标准。W3C建议所有的web服务器除了支持&分隔符[6]之外,还支持分号分隔符,以便在HTML文档的url中允许应用程序/ www-form- urlencoding查询字符串,而无需实体转义&号。
Technically, the form content is only encoded as a query string when the form submission method is GET. The same encoding is used by default when the submission method is POST, but the result is not sent as a query string, that is, is not added to the action URL of the form. Rather, the string is sent as the body of the HTTP request.
从技术上讲,表单内容只有在表单提交方法得到时才被编码为查询字符串。当提交方法是POST时,默认情况下使用相同的编码,但是结果不会作为查询字符串发送,也就是说,不会添加到表单的操作URL中。相反,字符串作为HTTP请求的主体发送。
#2
29
Query String: ?strID=XXXX&strName=yyyy&strDate=zzzzz
before you redirect:
在你重定向:
string queryString = Request.QueryString.ToString();
Response.Redirect("page.aspx?"+queryString);
#3
14
Try like this.It should work
这样的尝试。它应该工作
Response.Redirect(String.Format("yourpage.aspx?strId={0}&strName={1}&strDate{2}", Server.UrlEncode(strId), Server.UrlEncode(strName),Server.UrlEncode(strDate)));
#4
6
~mypage.aspx?strID=x&strName=y&strDate=z
#5
4
This can be done by using:
这可以通过以下方法实现:
Response.Redirect("http://localhost/YourControllerName/ActionMethodName?querystring1=querystringvalue1&querystring2=querystringvalue2&querystring3=querystringvalue3");
#6
1
I use the AbsoluteUri and you can get it like this:
我用的是绝对uri,你可以这样理解:
string myURI = Request.Url.AbsoluteUri;
if (!WebSecurity.IsAuthenticated) {
Response.Redirect("~/Login?returnUrl="
+ Request.Url.AbsoluteUri );
Then after you login:
之后你登录:
var returnUrl = Request.QueryString["returnUrl"];
if(WebSecurity.Login(username,password,true)){
Context.RedirectLocal(returnUrl);
It works well for me.
这对我来说很有效。
#1
77
Query_string
(Following is the text of the linked section of the Wikipedia entry.)
(以下是*条目的链接部分。)
Structure
A typical URL containing a query string is as follows:
包含查询字符串的典型URL如下:
http://server/path/program?query_string
http://server/path/program?query_string
When a server receives a request for such a page, it runs a program (if configured to do so), passing the query_string unchanged to the program. The question mark is used as a separator and is not part of the query string.
当服务器收到这样一个页面的请求时,它会运行一个程序(如果配置为这样做的话),并将query_string不加修改地传递给程序。问号用作分隔符,而不是查询字符串的一部分。
A link in a web page may have a URL that contains a query string, however, HTML defines three ways a web browser can generate the query string:
web页面中的链接可能具有包含查询字符串的URL,但是HTML定义了web浏览器生成查询字符串的三种方式:
- a web form via the ... element
- 一个通过…元素
- a server-side image map via the ismap attribute on the element with a construction
- 通过元素上的ismap属性构建的服务器端图像映射
- an indexed search via the now deprecated element
- 通过现在已弃用的元素进行索引搜索
Web forms
The main use of query strings is to contain the content of an HTML form, also known as web form. In particular, when a form containing the fields field1, field2, field3 is submitted, the content of the fields is encoded as a query string as follows:
查询字符串的主要用途是包含HTML表单(也称为web表单)的内容。特别是,当提交包含字段field1、field2、field3的表单时,字段的内容被编码为如下所示的查询字符串:
field1=value1&field2=value2&field3=value3...
field1 = value1&field2 = value2&field3 = value3……
- The query string is composed of a series of field-value pairs.
- 查询字符串由一系列字段值对组成。
- Within each pair, the field name and value are separated by an equals sign. The equals sign may be omitted if the value is an empty string.
- 在每对中,字段名和值用等号表示。如果值是空字符串,则可以省略等号。
- The series of pairs is separated by the ampersand, '&' (or semicolon, ';' for URLs embedded in HTML and not generated by a ...; see below). While there is no definitive standard, most web frameworks allow multiple values to be associated with a single field:
- 这一系列的对是由ampersand, '&'(或分号,';',' ',' ',' ',' ' . ' ',' ',' ',' ' ' ',' ' ' ' ' ' ' ',' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' '见下文)。虽然没有确定的标准,但是大多数web框架允许多个值与单个字段关联:
field1=value1&field1=value2&field1=value3...
field1 = value1&field1 = value2&field1 = value3……
For each field of the form, the query string contains a pair field=value. Web forms may include fields that are not visible to the user; these fields are included in the query string when the form is submitted
对于表单的每个字段,查询字符串包含一对字段=值。Web表单可以包含用户不可见的字段;当表单提交时,这些字段包含在查询字符串中。
This convention is a W3C recommendation. W3C recommends that all web servers support semicolon separators in addition to ampersand separators[6] to allow application/x-www-form-urlencoded query strings in URLs within HTML documents without having to entity escape ampersands.
此约定是W3C推荐标准。W3C建议所有的web服务器除了支持&分隔符[6]之外,还支持分号分隔符,以便在HTML文档的url中允许应用程序/ www-form- urlencoding查询字符串,而无需实体转义&号。
Technically, the form content is only encoded as a query string when the form submission method is GET. The same encoding is used by default when the submission method is POST, but the result is not sent as a query string, that is, is not added to the action URL of the form. Rather, the string is sent as the body of the HTTP request.
从技术上讲,表单内容只有在表单提交方法得到时才被编码为查询字符串。当提交方法是POST时,默认情况下使用相同的编码,但是结果不会作为查询字符串发送,也就是说,不会添加到表单的操作URL中。相反,字符串作为HTTP请求的主体发送。
#2
29
Query String: ?strID=XXXX&strName=yyyy&strDate=zzzzz
before you redirect:
在你重定向:
string queryString = Request.QueryString.ToString();
Response.Redirect("page.aspx?"+queryString);
#3
14
Try like this.It should work
这样的尝试。它应该工作
Response.Redirect(String.Format("yourpage.aspx?strId={0}&strName={1}&strDate{2}", Server.UrlEncode(strId), Server.UrlEncode(strName),Server.UrlEncode(strDate)));
#4
6
~mypage.aspx?strID=x&strName=y&strDate=z
#5
4
This can be done by using:
这可以通过以下方法实现:
Response.Redirect("http://localhost/YourControllerName/ActionMethodName?querystring1=querystringvalue1&querystring2=querystringvalue2&querystring3=querystringvalue3");
#6
1
I use the AbsoluteUri and you can get it like this:
我用的是绝对uri,你可以这样理解:
string myURI = Request.Url.AbsoluteUri;
if (!WebSecurity.IsAuthenticated) {
Response.Redirect("~/Login?returnUrl="
+ Request.Url.AbsoluteUri );
Then after you login:
之后你登录:
var returnUrl = Request.QueryString["returnUrl"];
if(WebSecurity.Login(username,password,true)){
Context.RedirectLocal(returnUrl);
It works well for me.
这对我来说很有效。