Azure Website Debugging: The network connection to *.azurewebsites.net:4020 has been lost. Debugging will be aborted.

08 Sep 2016
September 8, 2016

Recently my colleagues and I created a lot of SharePoint provider-hosted addins – in our case that is just a MVC Website hosted on Azure that talks balk to SharePoint. And I have to say it is good fun because we could actually debug a production site/business application in case something unforeseeable happens (aka. bugs). And the integration in Visual Studio via the Cloud Explorer could not be simpler. Right click on the website, attach debugger and see the problem.

Attach debugger on your remote azure website - cant be easier!

Attach debugger on your remote azure website – cant be easier!

 

That worked a long time perfectly for us – but something changed and Visual Studio 2015 dropped the connection once a breakpoint is hit (sometimes even earlier). Strangely debugging still worked with Visual Studio 2013.

Symptoms

Attaching with a Visual Studio 2015 Debugger either from Cloud Explorer, Server Explorer or directly via “attach to process” attaches the debugger briefly (if at all) and then results in two errors:

  1. The web browser shows: 502 – Web server received an invalid response while acting as a gateway or proxy

    502 – Web server received an invalid response while acting as a gateway or proxy

     

  2. In Visual Studio 2015 an error box shows: The network connection to <>.azurewebsite.net:4020 has been lost. Debugging will be aborted.

    Debugging will be aborted

    Debugging will be aborted.

Fix

The fix is rather simple. In Visual Studio open Debug menu from the top and click on Options:

2016-09-07 14_33_50-Debug Options

Then click on Debugging > General and find the option “Enable UI Debugging Tools for XAML” and uncheck it. 2016-09-07 14_37_36-Options

After that, Debugging worked like a charm again.

Thank you!

I did not find that one out myself – the awesome Microsoft Support (I am looking at you Akash Khandelwal!) spent hours troubleshooting my problem. He early noticed that there is a something with WPF in the logs but we initially ruled that one out. After a while his team suggested to disable this option – and it worked!

During the debugging session I learned a lot about Azure Website troubleshooting – great stuff!

Max Melcher
Follow me!

Max Melcher

Maximilian Melcher (MCSE, MCPD) is a Principal Consultant working at Alegri International Services in Munich, Germany. Max is a specialist in SharePoint technologies focused on search, social computing, web content management and collaboration. Max has led SharePoint implementations for Dax 30 companies since 2009.
Max’s free time is spent on twitter (@maxmelcher) mostly with a good coffee in his hands.
Max Melcher
Follow me!
Tags: , ,
3 replies
  1. Vino says:

    Awesome, it worked 🙂

    Reply
  2. Mark S says:

    Thanks very much. It definitely worked for me.

    Using Visual Studio 2015

    Mark

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

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

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close