1

I am facing a strange problem on both my laptop and desktop computer.

In my solution I have an MVC 4 Web Api and the solution is started by Visual Studio 2013.
So If set the Web API project as startup project then When I type some url of the web api it hits the controller.

But if the startup folder is another project, like a website that consumes this web api, then the web api is just unreachable.

I even tried to hit the same url that works when web api is started in debug mode.

So, what could be wrong?

3 Answers 3

1

Most likely the issue is that web server is not running. Try hosting your web API in IIS with a fixed URL and port.

Or your try setting multiple start up projects like this:

  • In your Solution Explorer,
  • Select, Right click your solution.
  • On the Project menu, click Properties. The Solution Property Pages dialog box opens.
  • click Startup Project.
  • Click Multiple Startup Projects and set the project actions start.

enter image description here

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

2 Comments

The Web Api is hosted in IIS Express.
I have used a empty project template for creating the ASP.NET Web API. For some reason when starting in release mode it's just not hosted in IIS Expres. By adding it to the Multiple startup project the issue was solved. I have noticed the same problem with MVC 5 and Empty Web API project under Visual Studio 2013. My problem is solved now. Thank you Dalorzo!
0

Two possible ideas to try:

  1. Left click on the WebApi project, and open the properties window (F4 for shortcut key) ensure Always Start When Debugging is set to true
  2. When debugging your consumer application, right click on the WebApi Project, and click Debug > Start New Instance

If they don't work the best solution would be to host the WebApi application using IIS / IISExpress

Comments

0

I have found the actual problem. I am running Windows 7 x64 and Visual Studio 2013. I had to uncheck the Enable Edit and Continue checkbox under Tools->Options->Debugging.

Now I am using a single startup project in my solution and I can call the web api also when not in Debug mode.

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.