neel neel - 2 months ago 22
ASP.NET (C#) Question

Issue in Global.asax.cs page in MVC4

I my ASP.NET MVC 4 Project, my

Global.asax.cs
page shows the error on

WebApiConfig.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);
}
}
}

Answer

Make sure you have assembly System.Web.Http.WebHost.dll referenced. This is where GlobalConfiguration is.

Comments