0

I am just getting started here and would appreciate some help.

I created a MVC 4 Web API project (VS 2012) and a MSTest project in a solution.

I wrote a test method in MSTest and use the WebClient class to call into the Web API project with a URL like:

http://localhost:59466/api/values

I was hoping this would cause the Web API project to run and call the sample Values controller that is put in as a default.

When I run the tests, I get a test error "Unable to connect to server".

So how do I get the Web API app running so my MSTest project can call in to it?

2 Answers 2

1

If i understood your question. Most likely the url you posted is from Visual Studio development server rather than IIS. If you deploy your site to IIS and try that i believe your problem would be solved.

If you don't host your site in IIS your MSTest project cannot call it unless your site in running in dubug mode in Visual Studio.

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

1 Comment

What you said works. Another thing I found to work is to run IISEXPRESS from a command prompt. Use the /site: option to specify my project and it starts my web api. It is a little nicer because it shows a trace of request/response data that is helpful.
0

The Web API project has to be started before running MStest. I end up having two windows of Visual Studio 2012 and they open the same solution. One is used to start Web API and the other can run/debug tests using MSTest.

Comments

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.