I have a web api in my EPiServer application which previously worked fine. But suddenly I can't get it to run in IIS. Localhost works fine. It seems the web api is found, but the routing is wrong. I get this error message in postman when I run (...)/api/epi/helptexts:
{ "Message": "No HTTP resource was found that matches the request URI '(...)/api/epi/helptexts'.", "MessageDetail": "No type was found that matches the controller named 'helptexts'." }
This is the controller:
[RoutePrefix("api/epi")]
public class ContentController : ApiController
{
[HttpGet]
[Route("helptexts")]
[AllowAnonymous]
public HttpResponseMessage GetHelptextsNorwegian()
This is the webApiConfig.cs:
[InitializableModule]
[ModuleDependency(typeof(FrameworkInitialization))]
public class WebApiConfig : IInitializableModule
{
public void Initialize(InitializationEngine context)
{
GlobalConfiguration.Configure(config =>
{
config.MapHttpAttributeRoutes();
config.EnableCors();
var formatters = GlobalConfiguration.Configuration.Formatters;
var jsonFormatter = formatters.JsonFormatter;
var settings = jsonFormatter.SerializerSettings;
var enumConverter = new Newtonsoft.Json.Converters.StringEnumConverter();
jsonFormatter.SerializerSettings.Converters.Add(enumConverter);
settings.Formatting = Formatting.Indented;
config.Formatters.Remove(config.Formatters.XmlFormatter);
config.Routes.MapHttpRoute(
name: "DefaultEpiApi",
routeTemplate: "api/epi/{controller}/{id}",
defaults: new { id = RouteParameter.Optional });
});
}
This configuration works fine in another site. Can anyone point me in the right direction?
Hi!
I have a web api in my EPiServer application which previously worked fine. But suddenly I can't get it to run in IIS. Localhost works fine. It seems the web api is found, but the routing is wrong. I get this error message in postman when I run (...)/api/epi/helptexts:
{
"Message": "No HTTP resource was found that matches the request URI '(...)/api/epi/helptexts'.",
"MessageDetail": "No type was found that matches the controller named 'helptexts'."
}
This is the controller:
This is the webApiConfig.cs:
This configuration works fine in another site. Can anyone point me in the right direction?