ASP.NET MVC Routing to start at html page

前端 未结 4 1762
自闭症患者
自闭症患者 2020-12-20 12:01

I am using IIS 6. I think my problem is that I don\'t know how to route to a non controller using the routes.MapRoute.

I have a url such as example.com and I want i

4条回答
  •  时光说笑
    2020-12-20 12:26

    I added a dummy controller to use as the default controller when the root of the web site is specified. This controller has a single index action that does a redirect to the index.htm site at the root.

    public class DocumentationController : Controller
    {
        public ActionResult Index()
        {
            return Redirect( Url.Content( "~/index.htm" ) );
        }
    
    }
    

    Note that I'm using this a the documentation of an MVC-based REST web service. If you go to the root of the site, you get the documentation of the service instead of some default web service method.

提交回复
热议问题