Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
474 views
in Technique[技术] by (71.8m points)

asp.net mvc 2 - Firefox 6 Infinite Page Refresh With Page With Hash Tags

When Firefox updated to version 6 recently, a site I'm working on severely broke.

The site operates normally when browsing to any page without a hash tag but if you try to navigate to a page with a hash tag (e.g. #test) or refresh the page once a hash tag was applied, the page refreshes as quickly as it can infinitely.

This is a Asp.Net MVC 2 site created around a year and a half ago.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Turns out, this is an issue with an old version of MicrosoftAjax.js (the one that comes installed with Asp.Net MVC 2).

Open up the MicrosoftAjax.debug.js file and check the file version number. The top of this file will look like this if this is your problem:

 // Name:        MicrosoftAjax.debug.js
 // Assembly:    System.Web.Extensions
 // Version:     4.0.0.0
 // FileVersion: 4.0.20526.0

That's the version that contains this bug. The latest file version as of this writing is 4.0.30205.0. Upgrade to the latest version and the problem goes away. As mentioned in a comment by Nathan Fox, I got the latest version from the Microsoft cdn and more specifically the minified and debug versions.

For the curious, I traced the problem down in the javascript file.

The buggy version includes:

 if ((Sys.Browser.agent === Sys.Browser.Firefox) && window.location.hash && (!window.frameElement || window.top.location.hash)) {
      window.history.go(0);
 }

Which was corrected to the following in the newer version:

 if ((Sys.Browser.agent === Sys.Browser.Firefox) && window.location.hash && (!window.frameElement || window.top.location.hash)) {
      (Sys.Browser.version < 3.5) ?
      window.history.go(0) :
      location.hash = this.get_stateString();
 }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...