我怎样才能返回从ASP.NET Web服务的原始字节? [英] How can i return raw bytes from ASP.NET web service?

查看:96
本文介绍了我怎样才能返回从ASP.NET Web服务的原始字节?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果WebMethod的返回字符串它获取序列化为XML。

If the WebMethod returns string it gets serialized to xml.

我要回字节[] 与响应的ContentType - ?可我还需要指定它

I want to return byte[] with responding ContentType - can I also specify it?.

是否可以在ASP.NET Web服务的Web方法做了什么?

Can it be done in ASP.NET web service web method?

推荐答案

而不是一个Web服务,使用一个通用的处理程序(ashx的)。

Instead of a web service, use a Generic Handler (.ashx).

一个通用处理器接受GET / POST请求,使您能够完全控制通过的HttpContext输出的能力。

A Generic Handler accepts get/post requests and gives you the ability to completely control the output via the HttpContext.

我通常使用这些发送文件(PDF文件等)浏览器。

I typically use these for sending files (pdfs, etc) to the browser.

这篇关于我怎样才能返回从ASP.NET Web服务的原始字节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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