开发者

ASP.NET :is there a limit for parameter length in querystring?

I have a problem when passing parameters in querystring. I found that its values are null.

Below my code snippet:

page1 - here I am passing some parameters:

Response.Redirect(string.Format("Req开发者_Python百科uestReservationPage.aspx?plcName={0}&PLCIndex={1}&Email={2}&form={3}&to={4}&SR={5}&Comment={6}", lblPLCNameVal.Text, index, lblEmailVal.Text, DateTime.Parse(lblReqFromVal.Text).ToShortDateString(),DateTime.Parse(lblReqToVal.Text).ToShortDateString(), lblServReqNum.Text, lblYourCommentVal.Text));

page2 - here I am requesting its values:

cmbPLCRequest.SelectedIndex = Convert.ToInt32(Request.QueryString["PLCIndex"]);

txtEmail.Text = Convert.ToString(Request.QueryString["Email"]);
txtSR.Text = Convert.ToString(Request.QueryString["SR"]);           
txtComment.Text = Convert.ToString(Request.QueryString["Comment"]);
txtReqFromDate.Text =Request.QueryString["from"];
txtReqToDate.Text = Request.QueryString["to"];

but I found that both of Request.QueryString["from"] and Request.QueryString["to"] return null

any idea?


see this

The amount of data you can transfer on the QueryString is limited by a number of factors, but the one that seems to be the most restrictive is the space in your browser's address bar. The Internet Explorer versions 5 and 6 that I tested only allowed up to 2,047 characters while Netscape Navigator version 4 seemed to be able to handle up to 30,000 and I couldn't get version 6 much past 9,000.

See this MSDN article for other options instead of passing variables by using the querystring

EDIT: try storing your values in the POST parameters if you need large strings


Two problems: typo in the from - in the Redirect code you got it as form. Also, you better encode all the values to be fit for URL.. so the code will be:

Response.Redirect(string.Format("RequestReservationPage.aspx?plcName={0}&PLCIndex={1}&Email={2}&from={3}&to={4}&SR={5}&Comment={6}", 
   Server.UrlEncode(lblPLCNameVal.Text), 
   index, 
   Server.UrlEncode(lblEmailVal.Text), 
   Server.UrlEncode(DateTime.Parse(lblReqFromVal.Text).ToShortDateString()), 
   Server.UrlEncode(DateTime.Parse(lblReqToVal.Text).ToShortDateString()), 
   Server.UrlEncode(lblServReqNum.Text), Server.UrlEncode(lblYourCommentVal.Text)));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜