'System.Web.Http.HttpConfiguration' enthält keine definition für 'EnableQuerySupport'
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using InCubatize.Helpers;
namespace InCubatize
{
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
//1
////Create and instance of TokenInspector setting the default inner handler
//TokenInspector tokenInspector = new TokenInspector() { InnerHandler = new HttpControllerDispatcher(config) };
////Just exclude the users controllers from need to provide valid token, so they could authenticate
//config.Routes.MapHttpRoute(
// name: "Authentication",
// routeTemplate: "api/users/{id}",
// defaults: new { controller = "users" }
//);
//config.Routes.MapHttpRoute(
// name: "DefaultApi",
// routeTemplate: "api/{controller}/{id}",
// defaults: new { id = RouteParameter.Optional },
// constraints: null,
// handler: tokenInspector
//);
//end1
config.Routes.MapHttpRoute(name: "DefaultApiWithAction",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional });
config.Routes.MapHttpRoute(name: "DefaultApiWithActionAndTwoParams",
routeTemplate: "api/{controller}/{action}/{id1}/{id2}",
defaults: new { id = RouteParameter.Optional });
config.Routes.MapHttpRoute(name: "DefaultApiWithActionAndFiveParams",
routeTemplate: "api/{controller}/{action}/{id1}/{id2}/{id3}/{id4}/{id5}/{id6}",
defaults: new { id = RouteParameter.Optional });
//Old Code.
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
config.EnableQuerySupport();
//To disable tracing in your application, please comment out or remove the following line of code
//For more information, refer to: http://www.asp.net/web-api
var json = config.Formatters.JsonFormatter;
json.SerializerSettings.PreserveReferencesHandling =
Newtonsoft.Json.PreserveReferencesHandling.None;
config.Formatters.Remove(config.Formatters.XmlFormatter);
config.EnableSystemDiagnosticsTracing();
}
}
}
Immer die folgende Fehlermeldung:-
'- System.Web.Http.HttpConfiguration' enthält keine definition für 'EnableQuerySupport' und keine Erweiterungsmethode 'EnableQuerySupport'
die Annahme ein erstes argument vom Typ 'System.Web.Http.HttpConfiguration'
gefunden werden konnte (fehlt eine using-Direktive oder ein assembly
Referenz?)
Ich habe die version des Systems.web.http und seine richtige.
InformationsquelleAutor user3705566 | 2014-10-08
Du musst angemeldet sein, um einen Kommentar abzugeben.
In Visual Studio gehen Sie zu "Tools" und dann auf "Nuget-Paket-Manager" und dann "Paket-Manager-Konsole"
Führen Sie den nachstehenden Befehl und es wird das Problem zu beheben. Haben es getestet.
update-Paket von microsoft.aspnet.webapi -installieren
InformationsquelleAutor Navish Rampal
https://msdn.microsoft.com/de-de/library/jj918506(v=vs. 118).aspx
InformationsquelleAutor Rookian
Überprüfen System.Web.Http.OData.dll - dies ist, wo diese Methode aus, nach MSDN
Beachten Sie, dass diese Methode ist jetzt veraltet. msdn.microsoft.com/en-us/library/...
InformationsquelleAutor Alex Buyny