问题在MVC4的Global.asax.cs页 [英] Issue in Global.asax.cs page in MVC4
本文介绍了问题在MVC4的Global.asax.cs页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的ASP.NET MVC 4项目,我的的Global.asax.cs
页显示了
WebApiConfig.Register(GlobalConfiguration.Configuration);
GlobalConfiguration'这个名字并不在目前的情况下存在
块引用>我已经做了很多的控制器和视图,所有...我该如何解决这个问题,并恢复我的项目?
下面是我的code的上下文其余
使用系统;
使用System.Collections.Generic;
使用System.Linq的;
使用的System.Web;
使用System.Web.Http;
使用System.Web.Mvc;
使用System.Web.Routing;命名空间.....
{
//注意:有关启用IIS6 IIS7或经典模式的指令,
//参观http://go.microsoft.com/?LinkId=9394801
公共类MvcApplication:System.Web.HttpApplication
{
保护无效的Application_Start()
{
AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
}
}
解决方案请确认您已经装配
System.Web.Http.WebHost.dll
引用。这是GlobalConfiguration的。I my ASP.NET MVC 4 Project, my
Global.asax.cs
page shows the error onWebApiConfig.Register(GlobalConfiguration.Configuration);
The name 'GlobalConfiguration' does not exist in the current context
I have done many controllers and Views and all... How can I solve this issue and recover my project?
Here is the rest of my code for context
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Http; using System.Web.Mvc; using System.Web.Routing; namespace ..... { // Note: For instructions on enabling IIS6 or IIS7 classic mode, // visit http://go.microsoft.com/?LinkId=9394801 public class MvcApplication : System.Web.HttpApplication { protected void Application_Start() { AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); } } }
解决方案Make sure you have assembly
System.Web.Http.WebHost.dll
referenced. This is where GlobalConfiguration is.这篇关于问题在MVC4的Global.asax.cs页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文