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.

4

2 回答 2

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;
    }
}
于 2014-07-31T19:14:09.500 回答
0

相反,您可以使用带有 Meta Refresh 标签的 default.htm 或 Index.htm 重定向到您的帮助。如果 Web API 托管在 IIS 中,这将起作用。

于 2016-10-06T10:16:11.040 回答