# 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/螢幕快照%202017-04-01%20上午9.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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jen-hsuan-hsieh.gitbook.io/asp-net/chapter1/1.1.the-complete-asp.net-mvc-5-course/11getting-started/113create-mvc-app.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
