调用webservice时,我需要在调用特定操作时更改响应文本。HttpModule更改响应
因此,我创建了HttpModule来捕获响应并对其进行更改。
代码如下:
public class BeginEnd : IHttpModule
{
public void Init(HttpApplication context)
{
context.EndRequest += (o, e) =>
{
HttpContext currContext = HttpContext.Current;
NameValueCollection collection = currContext.Request.QueryString;
if (collection.Count > 0
&& collection["op"] != null
&& collection["op"] == "ChangeService")
{
string xmlOther = "<root>My Test</root>";
currContext.Response.Clear();
currContext.Response.Write(xmlOther);
currContext.Response.End();
}
};
}
public void Dispose()
{
}
}
所以你看,我只是清楚Response对象,并把我的文字。
是一个正确的方法来做到这一点?
它的工作,但我觉得我失去了一些东西
你觉得呢?