Try our conversational search powered by Generative AI!

Web api 2 - can´t find controllers in IIS

Vote:
 

Hi!

I´ve got some problems with routing and I tested a lot of ways of doing it, but when I make a call to my local IIS, for instance mysite.local/api/test it´s not working (404), but if I test localhost:54303/api/test it works just as expected. What are I missing? I´m using EpiServer 8. 

[InitializableModule]
    [ModuleDependency(typeof(ServiceContainerInitialization))]
    public class WebApiConfig : IInitializableModule
    {
        public static void Register(HttpConfiguration config)
        {
            config.MapHttpAttributeRoutes();
        }

        public void Initialize(InitializationEngine context)
        {
            GlobalConfiguration.Configure(Register);
        }

        public void Uninitialize(InitializationEngine context)
        {
        }
    }
[RoutePrefix("api/test")]
    public class TestController : ApiController
    {
        [Route("")]
        [HttpGet]
        public HttpResponseMessage Index()
        {
            return ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new { justsomejson = "sfdg" });
        }
    }



#118843
Mar 16, 2015 14:16
Vote:
 

Changing NET.Framework 4.5.1 to 4.5.2 solved it.

#118922
Mar 17, 2015 14:07
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.