I'm using asp.net mvc 5.I'm doing the following tutorial, http://venkatbaggu.com/signalr-database-update-notifications-asp-net-mvc-usiing-sql-dependency/
but in the Global.sax file it says that "WebApiConfig does not exist in current context".why is that?
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);
}
Do you have a WebApiConfig.cs file in your App_Start folder? If you take a look at the source that the tutorial references in github then the WebApiConfig file is as follows:
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 }
);
}
}
}
Take a look at the App_Start folder on the github repository: https://github.com/venkatbaggu/signalrdatabasenotifications/tree/master/SignalRDbUpdates/App_Start
For me, I had moved the code folder, and for some reason the
WebApiConfig.cs
AuthConfig.cs
Filter.cs
BundleConfig.cs
had been excluded from the project, reincluded them and it worked again. Because the folder wasn't expanded I never realised that they had been excluded.
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