?????????????? {
?????????????????????? filters.Add(new HandleErrorAttribute());
?????????????? }
?????? }
}
感觉好像没有这个文件也不要紧
7.App_Start目录中建立RouteConfig.cs文件,内容:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace WebApplication1
{
?????? public class RouteConfig
?????? {
?????????????? public static void RegisterRoutes(RouteCollection routes)
?????????????? {
?????????????????????? routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
?????????????????????? routes.MapRoute(
?????????????????????????????? name: "Default",
?????????????????????????????? url: "{controller}/{action}/{id}",
?????????????????????????????? defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
?????????????????????? );
?????????????? }
?????? }
}
要用到MVC的,这个文件是最主要的话,用到MVC的路由创建
8.项目根目录下建立Global.asax文件,在Application_Start中注册一下上面建立的二个类,主要内容:
?????????????? protected void Application_Start(object sender, EventArgs e)
?????????????? {
?????????????????????? AreaRegistration.RegisterAllAreas();
?????????????????????? FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
?????????????????????? RouteConfig.RegisterRoutes(RouteTable.Routes);
?????????????? }
9.运行项目,就可以看到界面出来了,不过好像在CSHTML中的智能提示是没有的,不知道怎么弄,先这样吧!!!
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/jisuanjixue/article-64986-4.html
鹅肝