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

2
  • The Web Api is hosted in IIS Express. Feb 3, 2014 at 9:44
  • 1
    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! Feb 3, 2014 at 21:50
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

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.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.