您的位置:首页 > Web前端 > HTML

Opening Default document on IIS (HTML With WebAPI)

2015-12-11 13:52 751 查看
Question:

I've a deployed ASP.NET Web API with a website on the same folder that consume it.

When I type the URL on the Browser such as http://domain.com/ it returns a 404, but if I typehttp://domain.com/index.html it works!

I wanna know if there's a way to configure it on Web API route, define a default route for it, redirecting to my http://domain.com/index.html when I type http://domain.com/

I've tried ti put this on Web.Config without success:

<defaultDocument enabled="true">
<files>
<add value="/index.html" />
</files>
</defaultDocument>

Also, I set up my IIS to only accept index.html default document. no success =/

Any ideas?

Answers

activeoldestvotes

up vote1down voteaccepted
I'm not sure if this is the best way to achieve this, I just edited my RouteConfig.cs such this:

public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

routes.MapRoute(
name: "Default",
url: "index.html"
);
}
}

Now I can get http://domain.com works perfectly!

I'd love If anyone have a best way to achieve this!

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: