0

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 WebRequest to 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?

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

Does Debugger.Launch() help you here?

1 Comment

No sorry, I am running the test project under the debugger, so it is already launched
0

There are a few ways to debug it.

  1. In your service code, create a log file and write all exceptions to it. If possible add in all stack trace that will give you some idea where the error might be.
  2. Create a Winform test project within your web service and throw in dummy data to your service code and test the web service (so everything is in one solution).

1 Comment

I mentioned in the question that I am logging the error, but it is not enough, and I also mention that the test project is actually in the same solution as web application

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.