window.onbeforeunload not running

After recently upgrading to Visual Studio 2013 I noticed that a page which uses the window.onbeforeunload event wasn't calling the method I wrote.
Checking the chrome console I was seeing this instead of the function I had written.


The culprit is Browser Link, a technology introduced in VS 2013 to provide a link between VS and any open browsers (presumably to make debugging easier instead of existing just to create this problem).

If you want to disable it you can do so in two ways:

  • Uncheck "Enable Browser Link"

  • Disable it in web.config on a project-by-project basis
        <add key="vs:EnableBrowserLink" value="false" />

Share Tweet Send