0

I want to have BlaController : ApiController, with BlaController located in /Areas/XXX/ ( or namespace MySolution.Areas.XXX.Controllers )

The problem is that when I browse to http://localhost:1935/XXX/Bla/SomeAction I get 404.
Normal controllers (: Controller) do not throw 404.


Note: SomeAction would be for example "public string SomeAction() { return "hi"; }", within BlaController *Note 2: Tried* http://localhost:1935/api/Bla/SomeAction and didn't work either

sports
  • 7,851
  • 14
  • 72
  • 129

1 Answers1

1

Based on this SO question, looks like you need to build your own HttpControllerFactory in order to support Areas with WebAPI.

The question references an article on how to do this: http://netmvc.blogspot.com/2012/03/aspnet-mvc-4-webapi-support-areas-in.html

Hope this helps.

UPDATE: Thanks to Bertrand who pointed to an updated article about WebApi support for Areas (which is still doesn't have by default). The updated link is http://netmvc.blogspot.be/2012/06/aspnet-mvc-4-webapi-support-areas-in.html

Community
  • 1
  • 1
David Hoerster
  • 28,421
  • 8
  • 67
  • 102
  • 2
    There's no `HttpControllerFactory` in WebApi anymore. It can be done with a custom `HttpControllerSelector`. Andrew Malkov wrote a new version of that article you're linking to. http://netmvc.blogspot.be/2012/06/aspnet-mvc-4-webapi-support-areas-in.html – Bertrand Marron Sep 07 '12 at 13:52