传递查询字符串中的字节数组 [英] Pass Array of bytes in query string

查看:112
本文介绍了传递查询字符串中的字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要使用查询字符串发送图像的字节数组

首先我使用以下字符将字节转换为字符串:

 MemoryStream ms =  new  MemoryStream(); 
Image img = Image.FromFile( @ C:\Hydrangeas.jpg) ;
img.Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg);





然后在查询字符串中发送ms.ToArray()但问题是查询字符串太长而且它不起作用!!!



顺便说一下,它使用URL发送到点击一次的应用程序。



有没有办法缩小发送的字符串



是否有另一种使用查询字符串发送字节数组的方法



任何人都可以提供帮助吗?

解决方案

不要。找到一个不同的解决方案。



问题是查询字符串的最大长度不大,但也没有定义。 IE具有整个URL的最大长度+查询字符串为2,083个字符 http://support.microsoft.com/kb/208427 [ ^ ]这是字符,而不是字节 - 因为URL和查询字符串应该是人类可读的,你看的实际字节数要少得多!



事实上,你必须提出问题表明你在某个地方做出了一个非常错误的决定,你需要回过头来重新思考你的设计。我不能建议更好的方法,因为我不知道为什么你认为这首先是必要的!


你能否将字节转换为base64字符串并尝试?

I have array of bytes for an image that i want to send it using query string
First I convert the bytes to string using :

 MemoryStream ms = new MemoryStream();
Image img = Image.FromFile(@"C:\Hydrangeas.jpg");
img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);



then send ms.ToArray() in query string but the problem is that the query string is too long and it doesn''t work !!!

By the way it''s sending to click-once application using URL.

Is there a way to minify the sent string
OR
is there a another way to send array of bytes using querystring

Any one can help ?

解决方案

Don''t. Find a different solution.

The problem is that the max length of a query string is not large, but it also isn''t defined. IE has a maximum length of the entire URL + Query string of 2,083 characters http://support.microsoft.com/kb/208427[^] and that is characters, not bytes - since the URL and querystring are supposed to be human readable, you are looking at a lot less actual bytes than that!

The fact that you have to ask the question indicates that you have made a very wrong decision somewhere, and you need to go back and re-think your design a little. I can''t suggest a "better way" because I have no idea why you think this is necessary in the first place!


Can you convert the bytes to a base64 string and try?


这篇关于传递查询字符串中的字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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