You are currently viewing Operation Not Legal in the Current State – Debugging ASP.NET Core

Operation Not Legal in the Current State – Debugging ASP.NET Core

Operation Not Legal in the Current State – The other evening I was playing around with an ASP.NET Core application. When I started debugging it, I immediately saw an error message pop up that said

Unable to start program ‘[http]://localhost:59676/’. An operation is not legal in the current state.

It was a bit of a head scratcher, so I decided to restart the debug session and see if the problem resolved itself. This didn’t help and I saw the same error again.

Operation Not Legal in the Current State

Operation Not Legal in the Current State?

I also saw that my Chrome browser had started up, but it wasn’t showing my web page. It was stuck on a notification page telling me that JavaScript debugging is now enabled in Visual Studio 2017 for Chrome.

IF YOU CAME HERE FOR SOMETHING ELSE —> TRY THE FOLLOWING LINKS INSTEAD:

This got me thinking…. if it is a feature, it must be able to be switched off.

Disabling JavaScript debugging

I then went to Tools > Options. In the search box, I typed javascript.

The option Enable JavaScript debugging for ASP.NET (Chrome and IE) was checked. I went ahead and unchecked this and clicked on the OK button. I then started another debug session.

debugging dotnet core

Sure enough, the error message was gone.

Not a fix

While I agree that this isn’t a fix, but more of a workaround… there is an investigation into the issue at the moment. Have a look at Chrome debugging crashes VS with “An operation is not legal in the current state.” on the Developer Community Forum. Client-side debugging of web applications in Chrome is really a very nice feature and something I will definitely use. For now however, it seems that for my ASP.NET Core application I will have to wait a bit longer.

To read up more on debugging web applications client-side in Visual Studio 2017, have a look at an article introducing the feature: Client-side debugging of ASP.NET projects in Google Chrome

My article originally appeared here

Dirk Strauss

As a seasoned software developer with a long-standing career in C# and Visual Studio, I have had the privilege of working with a number of companies and learning from some of the most talented individuals in the industry. In addition to my professional experience, I have authored multiple books on topics such as C#, Visual Studio, and ASP.NET Core. My passion for programming is unwavering, and I am dedicated to staying current with the latest technology and sharing my expertise with others.