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); } } }
How to add global. asax file: Select Website >>Add New Item (or Project >> Add New Item if you're using the Visual Studio web project model) and choose the Global Application Class template. After you have added the global.
The Global. asax file is a special file that contains event handlers for ASP.NET application lifecycle events. The route table is created during the Application Start event. The file in Listing 1 contains the default Global. asax file for an ASP.NET MVC application.
Global. asax is an optional file which is used to handling higher level application events such as Application_Start, Application_End, Session_Start, Session_End etc. It is also popularly known as ASP.NET Application File. This file resides in the root directory of an ASP.
Application_Start. The Application_Start event is fired the first time when an application starts. Session_Start. The Session_Start event is fired the first time when a user's session is started. This typically contains for session initialization logic code.
Make sure you have assembly System.Web.Http.WebHost.dll
referenced. This is where GlobalConfiguration is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With