我怎么可以从头开始创建一个HTTP响应? [英] How can I create an http response from scratch?

查看:164
本文介绍了我怎么可以从头开始创建一个HTTP响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有code返回HTTP响应,但它也包括在网页中的内容。我怎么可以从头开始创建的响应,所以它不会包含任何东西,除了我放了?

我现在的code:

  GCheckout.AutoGen.NotificationAcknowledgment响应=新GCheckout.AutoGen.NotificationAcknowledgment();
response.serialnumber =的serialNumber;
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.BinaryWrite(GCheckout.Util.En codeHelper.Serialize(响应));
HttpContext.Current.Response.Status code = 200;


解决方案

你设置了状态code和写出来的响应内容,通话的 HttpContext.Current.Response.End() 停止当前请求的执行。

I have code that returns an http response, but it also includes the content of the page. How can I create a response from scratch so it won't include anything except what I put in it?

My code now:

GCheckout.AutoGen.NotificationAcknowledgment response = new GCheckout.AutoGen.NotificationAcknowledgment();
response.serialnumber = serialNumber;
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.BinaryWrite(GCheckout.Util.EncodeHelper.Serialize(response));
HttpContext.Current.Response.StatusCode = 200;

解决方案

After you've set the status code and written out the response content, call HttpContext.Current.Response.End() to stop the execution of the current request.

这篇关于我怎么可以从头开始创建一个HTTP响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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