I am writing some integration tests for an ASP.NET MVC application, and I am wondering how you can get breakpoints to be hit in the web application after firing a web request at the application.
To give a bit more background, this is what is currently happening:
- In a separate class library project in the same solution as my MVC project I spin up IIS Express and point it at the location of my MVC app
- Build some data in a POCO object
- Parse the object to a string of name value pairs
- Post the string as the body of a
WebRequestto an MVC action method
I know all this is working, as I am getting a 500 back, and my app is logging exactly where in the app an error is being thrown. However, this on it’s own is not enough information, I would like the symbols to be loaded for the MVC app so that when I fire the request off I can hit a breakpoint in the web app.
Anyone any idea how to do this?
As long as your app is compiled as Debug, you can attach to the IIS Express process from Visual Studio.
In visual studio, select Attach to process from the Tools menu, and select IIS Express from the list of processes.
After attaching to the process, make a request and it should stop at any breakpoints you have set.