Taras Kovalenko Taras Kovalenko - 1 year ago 96
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:

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?

Answer Source

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");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download