WebApiConfig does not exist in the current context

I am using asp.net mvc 5. I am doing the following tutorial, http://venkatbaggu.com/signalr-database-update-notifications-asp-net-mvc-usiing-sql-dependency/

but the Global.sax file says that "WebApiConfig does not exist in the current context." Why is this?

here are some codes

protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);
        GlobalConfiguration.Configure(WebApiConfig.Register); //this is where error shows
        //Start SqlDependency with application initialization
        SqlDependency.Start(connString);
    }
+4
source share
3 answers

Do you have a WebApiConfig.cs file in the App_Start folder? If you look at the source that links to the tutorial on github, then the WebApiConfig file looks like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;

namespace SignalRDbUpdates
{
    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }
    }
}

App_Start github: https://github.com/venkatbaggu/signalrdatabasenotifications/tree/master/SignalRDbUpdates/App_Start

+7

, , ?

, , WebApiConfig.cs.

, , , .

, ?

SqlDependency.Start(connString);

.

EDIT: , :

: 'e:\BlogDemos\SignalRDbUpdates\SignalRDbUpdates\Global.asax.cs'

, "" . Managaed Pipilene Mode Classic Integrated ( ) .

0

For me, I moved the code folder, and for some reason

WebApiConfig.cs
AuthConfig.cs
Filter.cs
BundleConfig.cs

was excluded from the project, re-enabled them, and he worked again. Since the folder was not expanded, I never realized that they were excluded.

0
source

All Articles