
新的项目需要运行在WIN2003上,又不想用ASPX了,只好用回ASP.NET MV.0了,可是在VS2017中已经没有MV的模板了,网上下载的安装了也没有,只好把以前的MV的项目拿 出来看了一下,看看怎么由空白项目建立起来,步骤如下:
1.VS2017中建立空白的WEB项目,记得选择.NET 4.0版本的

2.NUGET包中搜索ASP.NET MVC,不要下5.0的那个版本,要下4.0的那个版本

3.自己手动建立Controllers文件夹,里面建立HomeController.cs类文件,文件内容
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Web.Http;
using System.Web.Mvc;
namespace WebApplication1.Controllers
{
public class HomeController : Controller
{
public ActionResult Index() {
ViewBag.mes = "niunan hahaha ...";
return View(); }
}
}
4.自己手动建立Views文件夹,里面建立Home文件夹,里面建立Index.cshtml文件,文件内容:
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta content="width=device-width" />
<title></title>
</head>
<body>
<div>
这是MVC示例页
@ViewBag.mes
</div>
</body>
</html>
5.在Views文件夹下建立Web.config文件,内容:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-64985-1.html
我才看到因为我还没有每天刷微博的习惯
多170艘还好呢
就是开战之时