ProtoAspx
Integrating Prototype and ASP.Net to create the next generation of web applications

Serving javascript with asp.net

April 23rd, 2008 . by Loris

If you’re creating an aspx page that serves javascript, be sure to choose the application/x-javascript content encoding instead of the usual text/javascript.

I found out today that text/javascript will work fine in any browser, except for Internet Explorer. Changing it to application/x-javascript does the trick, however.

In case you’re wondering, the content type is easily changed by adding:

Response.ContentType = "application/x-javascript";

in the page_load event (or the onLoad method).


Leave a Reply

Name

Mail (never published)

Website