Web Api Help Page - Redirect to MVC help page

1.5k Views Asked by At

I've a Web Api Service in C# and I created a Help Page, that added a folder "Areas" with a MVC project.

I tried to make my SERVICE/help page into my default page, changing the controller on the routing but of course, I couldn't do it because "help" is not a controller in my Web Api Service.

How can I redirect to the help page by default when someone acess to my service?

Thanks and kind regards.

2

There are 2 best solutions below

0
On BEST ANSWER
public class IndexController : ApiController
{
    [AllowAnonymous]
    [Route("")]
    public HttpResponseMessage GetIndex()
    {
        var response = Request.CreateResponse(HttpStatusCode.Moved);
        string fullyQualifiedUrl = Request.RequestUri.GetLeftPart(UriPartial.Authority);
        response.Headers.Location = new Uri(fullyQualifiedUrl + "/help");
        return response;
    }
}
0
On

Rather You could have default.htm or Index.htm with Meta Refresh tag which redirects to your help. This will work if Web API to be hosted in IIS.