Brandon Clapp
Brandon Clapp

Reputation: 70463

Web API Routing - Returning 404

I have a Web API project in MVC 4 but cannot find the URL to my web service. Rather than MVC, I am actually just using the C (controller) as I'm not returning a view and my model is located in an external project.

I'm using the default route, which is api/{controller}/{id}. The name of my controller is RESTController (I know, probably wasn't the best name) and is located at ~/Controllers/RESTController.cs

Based on naming convention, it seems that my web service should be located at localhost:port/api/REST but I'm just getting a 404 resource cannot be found error (no XML representation of the object returned or anything). Is this the expected behavior without a view?

The funny thing is that I also have a SOAP API in an external project that is actually just returning the REST API result and it works as it should. Doing unit tests on my methods passes... I just can't access it from a browser. I've tried every url imaginable.

Basically...

  1. Would there a way to debug this? (ie. Turning on ASP.NET directory listing)

  2. Does not having a view effect what is shown in the browser?

  3. Shouldn't the browser return an XML file representing the object?

  4. Am I missing something obvious?

Upvotes: 1

Views: 437

Answers (1)

Brandon Clapp
Brandon Clapp

Reputation: 70463

Nevermind, I'm a moron. I found the problem... At some point I accidentally drag and dropped (drug and dropped past tense?) my Global.asax file into my Views folder... therefore my routes were not getting registered.

Working as intended now.

Upvotes: 1

Related Questions