首先打开visual Studio,点击文件-新建项目
选择Asp.NET Web应用程序(Net.Farmework),下面选择好要保存的位置 改写文件名和项目名称
然后点击确定
选择 “空”这个文件然后点击下面的MVC -点击确定。
案例:用MVC写出邮箱登录页面
在Controllers文件中创建名为Home的控制器。然后在这个Home文件里Index上单击右键添加视图
然后会在Views文件下的Home文件中创建一个Index文件在这个文件中写登录邮箱的代码
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>邮箱登录页面</title>
</head>
<body>
<form action="~/Home/Login" method="post">
<p>
<img src="~/Images/aliyun.PNG" alt="" />
</p>
<center>
<table border="1" cellpadding="80" cellspacing="0" width="800">
<tr>
<td><img src="~/Images/alimail.jpg" alt="" /></td>
<td>
<font face="微软雅黑">登录名:</font><br /><br />
<input type="text" name="txtName" value="" /><BR /><BR />
<font face="微软雅黑">登录密码:</font><br /><br />
<input type="password" name="txtPwd" value="" /><br /><br />
<input type="image" src="~/Images/btn.png" /><br />
<span style="color:red">@TempData["ErrInfo"]</span>
</td>
</tr>
</table>
</center>
</form>
</body>
</html>