I got the same error "The operation is not legal in the current state" when I started the project in Google Chrome, stopping the project and then closing all the chrome instances, fixed the problem.
I think this is due to the fact that visual studio cannot connect to a chrome instance for debugging.
Chtiwi malek
source share