How can I create an http response from scratch?

2019-07-07 02:41发布

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;

1条回答
老娘就宠你
2楼-- · 2019-07-07 03:28

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.

查看更多
登录 后发表回答