在aASP.Net中发送Base64编码查询字符串的问题 [英] Issue with sending Base64 encoded query string in aASP.Net

查看:21
本文介绍了在aASP.Net中发送Base64编码查询字符串的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在.Net 3.5中创建一个网站,我正在将该字符串转换为Base64String以通过querystring发送它.Response.Redirect适用于较小的字符串.但是,如果原始字符串大小为1670,则response.redirect会导致错误找不到页面".

item是下面的代码片段中的字符串.

byte [] data = Encoding.Default.GetBytes(item);返回Convert.ToBase64String(data)

有人可以帮助解决这个问题吗?

解决方案

不应将查询字符串用于长值-尽管它取决于浏览器和Web服务器的确切最大安全长度,但绝对不安全超过约2000个字符,我会警惕要依赖于255以上.解决方案是改用POST请求,或者可能将数据保存在服务器上,并在查询字符串中将键传递给它.

I am creating a web site in .Net 3.5 , I am converting the string into Base64String to send it through querystring. The Response.Redirect works fine for smaller string. But if the original string size is 1670, the response.redirect results in error "Page can not be found".

item is the string in below code snippet.

byte[] data = Encoding.Default.GetBytes(item); return Convert.ToBase64String(data)

Can any one please help in resolving this?

解决方案

A query string shouldn't be used for long values - while it depends on the browser and web server exactly what the maximum safe length is, it's certainly not safe above about 2000 characters, and I'd be wary about relying on it above 255. The solution is to use a POST request instead, or possibly to save the data on the server and pass a key to it in the query string.

这篇关于在aASP.Net中发送Base64编码查询字符串的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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