I'm working on a webApi application, and the api I want to get is the following:
- api/v1/lists/?params...
- api/v1/meta/?params...
- api/v1/debug
There are ApiControllers that work fine for "lists" and "meta" routes, but api/v1/debug
should return a static html page.
I could think of two ways of implementing it:
- via special controller that would return something like
View("mypage.html")
or - configure routes in WebApiConfig to redirect requests like
api/v1/debug
tomypage.html
However, I couldn't get working version of any of these ways: there is no content type for HttpResponseMessage
like HtmlContent
or similar, so I can't do smth like
config.Routes.MapHttpRoute(
name: "Debug",
routeTemplate: "api/v1/debug/",
defaults: new { controller = "Debug" }
);
...
public class DebugController:ApiController
{
public HttpResponseMessage Get()
{
return new HttpResponseMessage()
{
Content = new HtmlContent("mypage.html");
};
}
}
and I can't get right redirection in WebApiConfig:
//this results into 400 status code:
config.Routes.MapHttpRoute("Default", "api/v1/debug/", "~/mypage.html");
Could you please tell me what would be the right solution for this problem? And is it possible at all to combine static html pages with Action Results in WebApi application?