天天看点

c# webapi修改默认启动项

c# webapi修改默认启动项

如我原来的webapi,默认启动的是一个html,这个是写在web.config里

<location path="test/welcome.html">
     <system.webServer>
       <staticContent>
         <clientCache cacheControlMode="DisableCache" />
       </staticContent>
     </system.webServer>
   </location>现在把这个去掉,在global.cs中加如下代码
Application_Start
 RouteTable.Routes.MapHttpRoute(

                    name: "DefaultApi",

                    routeTemplate:"{controller}/{action}/{id}",

                    defaults: new { controller = "DB", action = "CreateDb", id = "1" }

                 );