How can I create an http response from scratch?

别来无恙 提交于 2019-12-10 21:06:50

问题


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:


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.



来源:https://stackoverflow.com/questions/11180847/how-can-i-create-an-http-response-from-scratch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!