What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 128 Stack Exchange communities.

During today's maintenance I've noticed an annoying side effect to certain error pages. I happened to end up on http://workplace.stackexchange.com/error?aspxerrorpath=/ when trying to navigate to The Workplace. An interesting side effect of that error scheme is that if you refresh that page, even after the error no longer occurs, you'll continue getting the error page, as if the site was still down. It's because the error redirects you to a URL that will always show you the error.

Since it's an aspx error not a "normal" error like the 404 pages I'm not sure it can be changed, but ideally if you hit an error page you shouldn't be "stuck" on that error page. The error was fleeting, but the error URL scheme isn't.

share|improve this question
2  
I find this incredibly irritating too. And I sometimes continue refreshing not realizing the URL changed and I need to change it back to the URL I wanted. –  animuson Sep 16 '12 at 3:25
1  
This was a limitation of MVC3, we'll take a look again if we can do anything about it with MVC4. –  Nick Craver Sep 16 '12 at 10:44
add comment

2 Answers 2

For modern browsers, maybe window.history.pushState can help? On the client side, in the HTML:

<script>
  window.history.pushState(null, 'Oops! Something Bad Happened!', '/')
</script>

This would change the URL as shown in the location bar into that of the homepage, without reloading the current page. Hence: the error page would still be shown, but when refreshing the browser, the homepage would be loaded instead.

I don't know if this needs relative URLs to be changed (maybe clicking relative URLs now also uses the new URL as the base), but it seems the error page doesn't have any anyway. Also, if the error page originated from a POST, a refresh might be a POST too. To avoid that, one would first need to redirect using GET, to show the error page. And after that fire the JavaScript.

(One can easily try when viewing this very page: just type javascript: in the location bar and paste the above line. For Firefox you'll need Firebug's console instead; Firefox doesn't allow all JavaScript in the location bar anymore.)

share|improve this answer
add comment

MVC4 has come and been deployed, but we still don't have a good solution.

It'd be nice to have, but I've got to basically table this for the foreseeable future.

share|improve this answer
    
window.history.pushState(null, 'Oops! Something Bad Happened!', '/') ...? –  Arjan Sep 27 '12 at 21:15
1  
@Arjan - by the time our code can act we don't have anything about the request beyond the uri; no query strings, no user sessions, nada. It's hard to recover reasonably in the face of an arbitrary error there, we'd be GET'ing things that were originally POST'd, refreshing things that couldn't possibly work (due to missing parameters) and all sorts of fun there. I'd rather reliably broken than flakily fixed. –  Kevin Montrose Sep 27 '12 at 21:18
    
The above snippet would indeed not keep the URL that caused the error (though the aspxerrorpath=/ suggests you might actually know that), but make a refresh show the homepage instead. I'd like that much better than the current behaviour? Or maybe indeed a browser refresh might be a POST if the error originated from a POST? Then more JavaScript would be needed to first redirect to the error page one more time... –  Arjan Sep 27 '12 at 21:21
    
(But if "the foreseeable future" has a more robust solution then surely we can wait; I don't see too many errors at all!) –  Arjan Sep 27 '12 at 21:22
add comment

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .