码迷,mamicode.com
首页 > Windows程序 > 详细

Opening Default document on IIS (HTML With WebAPI)

时间:2015-12-11 15:09:50      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:

 

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?

 

 

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!

Opening Default document on IIS (HTML With WebAPI)

标签:

原文地址:http://www.cnblogs.com/haoliansheng/p/5038798.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!