Create the first ASP.NET MVC project. Use Visual Studio 2017/2019 to create an ASP.NET MVC5 application, the requirements are as follows:
(1) Select the "MVC" template to create an ASP.NET MVC application.
(2) Modify the contents of the homepage, about us and contact information pages respectively.
The page effect is shown in the figure:
Home page effect
About us effect
Contact method effect
Practice ideas:
- Select menu "File" → "New" → "Project", and select "ASP.NET Web Application (.NET Framework)" in the pop-up "New Project" dialog box.
- In the "New ASP.NET Web Application" dialog box, select the project template "MVC".
- Open the homepage file /Views/Home/Index.cshtml, delete the default content, add "Hello! Everyone, this is my first ASP.NET MVC application!" div for the description text, and write the style appropriately ( Use the existing class style jumbotron of the project).
@{
ViewBag.Title = "Home Page";
}
<div class="jumbotron">
<h2>Hello!大家好,这是我的第一个MVC。</h2>
</div>
- Open the About Us file /Views/Home/About.cshtml, delete the default content, and add corresponding description text (refer to the default content, use h2 to write the title and p to write the description content).
@{
ViewBag.Title = "关于我们";
}
<h2>@ViewBag.Title</h2>
<h3>@ViewBag.Message</h3>
- Open the contact file /Views/Home/Contact.cshtml, delete the default content, and add the corresponding description text (refer to the default content, use h2 to write the title and address to write the description).
@{
ViewBag.Title = "联系我们";
}
<h2>@ViewBag.Title</h2>
<address>
<div>地址:河北省唐山市丰南区正泰街29号</div>
<div>联系电话:0315-123456</div>
</address>
- Press the F5 shortcut key to start the application and browse the page.