首页 > Windows开发 > 详细

Opening Default document on IIS (HTML With WebAPI)

时间:2015-12-11 15:07:24      阅读:325      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!