# 1.1.3.Create MVC APP

## 1.Create a new MVC project

* 1.File -> NEW -> project -> Templetes -> Visual C# -> Web ->ASP .NET Web application
* 2.Select MVC

![](https://github.com/jenhsuan/asp-net/tree/4be758d868ba14011a3e816f30e65a6ee7ad7252/assets/%E8%9E%A2%E5%B9%95%E5%BF%AB%E7%85%A7%202017-04-01%20%E4%B8%8A%E5%8D%889.10.20.png)

## 2.Default files in the new MVC project

* App\_Data  &#x20;
  * Stored database.
* App\_Start
  * RouteConfig.cs
    * 當request符合url的規則時, 就會進行相對應的action及呼叫相對應的controller
    * 當request不符合url的規則時, 就會導入default的action及呼叫default的controller
    *   url的規則是controller/action/id        &#x20;

        ```
        routes.MapRoute(
          name: "Default",
          url: "{controller}/{action}/{id}",
          defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        );
        ```
    * 如果有個request是movies/popular, 則他會被送到MovieController的Popular()
    * 如果有個request沒有指定action, id, 或controller, 則他會被送到default
  * BundleConfig.cs
    * 設定js, css等bundle      &#x20;
* content : css files
* controllers
* fonts
* models
* scripts: js files
  * views: 與model的檔案是相對應的
    * shared
      * \_Layout.cshtml: 主頁面, @RenderBody()會再去呼叫controller對應的view頁面
* Global.asax.cs: 程式的進入點
* packges.config: 管理nuget套件的config, 如同npm
* startup.cs
* web.config
