Visual Studio 2017 unable to start program 'http://localhost', an operation in not legal in the current state

Error


Unable to start program 'http://localhost', an operation in not legal in the current state

Explanation


The reason why you are getting this error is because you are using Visual Studio in debugger mode while having chrome debugging window already opened.

Solution


There are two ways to fix this error :

1- Close any previous opened chrome debugging windows. Or

2- Turn off JavaScript debugging in chrome like this :

Go to Tools > Options > Debugging > General and uncheck the Enable JavaScript debugging for ASP.NET (Chrome and IE) option.

Uncheck Enable JavaScript debugging for ASP.NET (Chrome and IE)