1

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.

Leandro Bardelli
  • 10,561
  • 15
  • 79
  • 116

2 Answers2

1
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;
    }
}
Leandro Bardelli
  • 10,561
  • 15
  • 79
  • 116
0

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.

Nilesh Thakkar
  • 2,877
  • 1
  • 24
  • 43