如何在没有页面代码的情况下获得页面响应? [英] How to get Page Response without page code?
本文介绍了如何在没有页面代码的情况下获得页面响应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试以XML响应的形式发送对其他网站的请求的响应.
它以XML以及页面代码发送响应.但是我只想发送XML作为响应,而不发送页面代码:
Hi,
I am trying to send response to the request made by other website in the form of XML Response.
It sends the response in XML as well as page code. But i want to send only XML as response not the page code:
<DocumentElement><LeadMinimal><SSN>385213456</SSN><ZIP>10019</ZIP><GMI>2400</GMI><LeadTypeId>13</LeadTypeId><Status>Rejected</Status><Price>0</Price><L_LEADID>0</L_LEADID><MAXTIME>0</MAXTIME><Message>Duplicate Lead</Message></LeadMinimal></DocumentElement>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"><link href="App_Themes/IceBlueTheme/Controls.css" type="text/css" rel="stylesheet" /><title>
</title></head>
<body>
<form name="form1" method="post" action="Ping.aspx" id="form1">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE2MTY2ODcyMjlkZNbA51cgqMKs8IpT6MgyQBOzhFQ+nGMa+sveUrJfyUMY" />
<div>
</div>
</form>
</body>
</html>
请帮助我
Please help me
推荐答案
从.aspx页面中删除除ASP.Net页面声明之外的所有内容(即html部分,包括head,body ...).它应该看起来像这样:
From your .aspx page remove everything (i.e. html part including head, body...) except the ASP.Net Page declaration. It should look something like this:
<%@ Page language="c#" Inherits="MyPage" CodeFile="MyPage.aspx.cs" %>
使用通用处理程序(.ashx)代替ASP页面(.aspx)
您还应该设置Response.ContentType = "text/xml"
Use a generic handler (.ashx) instead of ASP page (.aspx)
You should also setResponse.ContentType = "text/xml"
好,我已经完成了
我已经附上了两条线
Page.Response.End();
Page.Response.Close();
Ok i have done
i have attached two lines
Page.Response.End();
Page.Response.Close();
这篇关于如何在没有页面代码的情况下获得页面响应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文