X
點擊此處開啟此網站的行動版。

技術支援討論區

Why does my Web Handler work with Internet Explorer, but not with Firefox

已張貼

I am trying to develop a web page that uses the Simile Timeline (http://code.google.com/p/simile-widgets/wiki/Timeline) with data from SQL Server.

In initial testing of my timeline I tested it with Example.xml, a static XML file in the correct format to be event data. I wrote the following in the appropriate place within mytimeline's Javascript: -

   var WebHandler = "Example.xml"
   tl.loadXML(WebHandler, function (xml, url) { eventSourceFamily.loadXML(xml, url) });

This worked fine with both Firefox and Internet Explorer. I then changed the assignment to

   var WebHandler = "GDBTimeline.ashx?Type=Family&Userid=" + getControlValue("input", "hdnUser");

so that invoked a web handler that could look up the SQL database and return the XML that I wanted, and wrote this web handler.

This works perfectly with Internet Explorer, but with FireFox the timeline band is blank. Yet when I examine the http traffic with Fiddler2 (http://www.fiddler2.com/fiddler2/) I see that with either browser there is a response from URL

  /GDB_pages/GDBTimeline.ashx?Type=Family&Userid=robertb

that returns the XML that it is supposed to.

I have previously used web handlers with Firefox before, with no problems. The Fiddler results conclusively show that the web handler is invoked, and returns the appropriate XML, and this XML is identical to the XML from the static test with Example.xml.

Where do I start looking for answers? I don't even know if this is a Simile problem, a Firefox problem, or an ASP.NET problem.

Thank you, Robert.

I am trying to develop a web page that uses the Simile Timeline (http://code.google.com/p/simile-widgets/wiki/Timeline) with data from SQL Server. In initial testing of my timeline I tested it with Example.xml, a static XML file in the correct format to be event data. I wrote the following in the appropriate place within mytimeline's Javascript: - var WebHandler = "Example.xml" tl.loadXML(WebHandler, function (xml, url) { eventSourceFamily.loadXML(xml, url) }); This worked fine with both Firefox and Internet Explorer. I then changed the assignment to var WebHandler = "GDBTimeline.ashx?Type=Family&Userid=" + getControlValue("input", "hdnUser"); so that invoked a web handler that could look up the SQL database and return the XML that I wanted, and wrote this web handler. This works perfectly with Internet Explorer, but with FireFox the timeline band is blank. Yet when I examine the http traffic with Fiddler2 (http://www.fiddler2.com/fiddler2/) I see that with either browser there is a response from URL /GDB_pages/GDBTimeline.ashx?Type=Family&Userid=robertb that returns the XML that it is supposed to. I have previously used web handlers with Firefox before, with no problems. The Fiddler results conclusively show that the web handler is invoked, and returns the appropriate XML, and this XML is identical to the XML from the static test with Example.xml. Where do I start looking for answers? I don't even know if this is a Simile problem, a Firefox problem, or an ASP.NET problem. Thank you, Robert.

由 robert.barnes@xtra.co.nz 於 修改

額外的系統細節

已安裝的外掛程式

  • Shockwave Flash 10.3 r183
  • Google Update
  • Google Updater pluginhttp://pack.google.com/
  • iTunes Detector Plug-in
  • Adobe PDF Plug-In For Firefox and Netscape "9.4.5"
  • 4.0.60531.0
  • GEPlugin
  • The QuickTime Plugin allows you to view a wide variety of multimedia content in Web pages. For more information, visit the QuickTime Web site.
  • Windows Presentation Foundation (WPF) plug-in for Mozilla browsers
  • DRM Netscape Network Object
  • DRM Store Netscape Plugin
  • Npdsplay dll

應用程式

  • User Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20100101 Firefox/7.0.1

更多資訊

提出問題者

Problem solved. The issue: Content Type was not correct.

Visual Studio creates the web handler with dummy code like this: -

   Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
       context.Response.ContentType = "text/plain"
       context.Response.Write("Hello World")
   End Sub

I wrote a database query that set a string variable to the XML I wanted: -

   Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
       Dim Outstring as string
       '   my logic to fill Outstring with XML
       context.Response.ContentType = "text/plain"
       context.Response.Write(Outstring)
   End Sub

This works with Internet Explorer. However it's not strictly correct: to make it work with other browsers as well,

       context.Response.ContentType = "text/plain"

should be

       context.Response.ContentType = "text/xml"

It now works with IE, FF, and Chrome, and presumably all others.

Problem solved. The issue: Content Type was not correct. Visual Studio creates the web handler with dummy code like this: - Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest context.Response.ContentType = "text/plain" context.Response.Write("Hello World") End Sub I wrote a database query that set a string variable to the XML I wanted: - Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest Dim Outstring as string ' my logic to fill Outstring with XML context.Response.ContentType = "text/plain" context.Response.Write(Outstring) End Sub This works with Internet Explorer. However it's not strictly correct: to make it work with other browsers as well, context.Response.ContentType = "text/plain" should be context.Response.ContentType = "text/xml" It now works with IE, FF, and Chrome, and presumably all others.