ASP.NET and Mozilla

Brian Jepson writes:

Is it unreasonable to expect ASP.NET controls to render perfectly on every browser? Are there things you can do to force the controls to render reliably? Has anyone had experience that refutes these claims?

We’re using ASP.NET and targetting HTML 4.01 and CSS. The browser detection code in ASP.NET detects recent versions of Netscape as being down-level browsers, so the controls will render HTML 3.2 with all the nasty inline stuff like <font> tags.

We edited web.config and added this:

<result type=”System.Web.HttpBrowserCapabilities, System.Web, Version=1.0.3102.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” />
<use var=”HTTP_USER_AGENT” />

That forces ASP.NET to render HTML 4.0 always, regardless of the browser. This was the right choice for us, but might not be for everybody; if you want to be selective about it, you could write a more elaborate browserCaps section which detects only Netscape 6.x or 7 or Mozilla 1.0 or whatever you’re after, and tell it just to use HTML 4.0 for that.

I haven’t run across any of the built-in controls that are IE specific. Some are more annoying than others (I can’t find a way to make the Calendar control render without adding tons of “style=” onto everything, for example), but everything works fine. What you’ll want to be careful about is the Microsoft add-on controls, some of which DO specifically target IE.

Leave a Reply

Your email address will not be published. Required fields are marked *