I have a very simple Generic Handler , which sends a simple alert to the client. I set the Content-Type
header to be application/x-javascript
, but what I get from server is a text/html
content type.
Here is the code of my generic handler:
public void ProcessRequest(HttpContext context)
{
context.Response.Clear();
context.Response.AddHeader("Content-Type", "application/x-javascript");
context.Response.ContentType = "application/x-javascript";
context.Response.Write("alert('javascript is here');");
context.Response.Flush();
context.Response.End();
}
Now, when I call this handler, via http://domain/path/handler.ashx
, what I get in Firebug is:
Any idea what's wrong?
PS: I want to create a script delivery service, and the script is authored on the fly. That's why I use a dynamic generic handler to serve this script.
Try clearing the response headers first:
context.Response.ClearHeaders()
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.