次の方法で共有


Thoughts on Changing Response Content Type

Question:

Hi

I´m using IIS 5 with ASP NET 2.0. I´ve develop an isapi application. the response content type its text/hml it´s posible chaged to text/xml

thanks

Answer:

In general, the handler which generates the response should own its Content-Type because it should be the only entity that knows the true "type of content" that is generated.

Thus, I recommend that you change the ISAPI application to have the right logic to output the right Content-Type.

If you cannot change the ISAPI application to send the right Content-Type, then you need to put this logic elsewhere:

  • ISAPI Filter - If you just want to change the Content-Type response header, then you can write a SF_NOTIFY_SEND_RESPONSE filter to modify that response header (assuming the response is logical). If you want to change response entity, then that is much harder because it requires buffering of response in SF_NOTIFY_SEND_RAW_DATA to perform the necessary modifications. This also turns off various caches and destroy static file performance for resources like text/xml or text/html.
  • ASP.Net can only change the output of static file or ASP.Net pages serviced by ASP.Net. In particular, ASP.Net cannot change the output of an ISAPI application.

I do not know WHY you want to do this, but what you want to do does not appear to be architecturally sound.

//David