Taras Kovalenko Taras Kovalenko - 3 months ago 28
HTML Question

web api start html page

I have web api project and I have *.html page and I need run it after run my project but I don't know how do it.
In MVC I use MapRoute like this:

routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);


But I don't know how do it in web api. I have next routes config:

config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{action}/{id}", new { id = RouteParameter.Optional });


and how to add other config for run my html page?
Thanks.

Answer

I use Like this code into the WebApi project:

public class DefaultController : ApiController
    {
        /// <summary>
        /// Default controller for render swagger UI 
        /// </summary>
        /// <returns></returns>
        [HttpGet, Route("")]
        public RedirectResult Index()
        {
            var requestUri = Request.RequestUri;
            return Redirect(requestUri.AbsoluteUri + "swagger/ui/index");
        }
    }