1

Error :=- AuthorizationServer.Api/Startup.cs(17,17): Error CS0246: The type or namespace name 'HttpConfiguration' could not be found (are you missing a using directive or an assembly reference?) (CS0246) (AuthorizationServer.Api)

i am using visual studio community for mac and first error was system.web.http error so i follow the approach listed here:-

MVC 5 on Mono: Could not load file or assembly 'System.Web.Entity' or one of its dependencies

Installed System.Web.Common.Http But Following Error It is Showing In my startup.cs File How to resolve This ? enter image description here

code:-

using AuthorizationServer.Api.Formats;
using AuthorizationServer.Api.Providers;
using Microsoft.Owin;
using Microsoft.Owin.Security.OAuth;
using Owin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http.Common;

namespace AuthorizationServer.Api
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            System.Web.Http.HttpConfiguration config = new System.Web.Http.HttpConfiguration();

            // Web API routes
            config.HttpConfigurationExtensions.MapHttpAttributeRoutes();

            ConfigureOAuth(app);

            app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);

            app.UseWebApi(config);

        }
Amey
  • 795
  • 8
  • 31

2 Answers2

3

after referencing the following NuGet: Microsoft ASP.NET Web API 2.2 Core Libraries

enter image description here

these are my Owin packages i have referenced:

enter image description here

startup.cs looks like this:

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        HttpConfiguration config = new HttpConfiguration();

        // Web API routes
        config.MapHttpAttributeRoutes();

        // Removed for clarity
        // ConfigureOAuth(app);

        app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);

        app.UseWebApi(config);
    }
}
Daniel
  • 9,491
  • 12
  • 50
  • 66
  • JWTAspNetWebApi-master/AuthorizationServer.Api/Startup.cs(20,20): Error CS1061: 'HttpConfiguration' does not contain a definition for 'MapHttpAttributeRoutes' and no extension method 'MapHttpAttributeRoutes' accepting a first argument of type 'HttpConfiguration' could be found (are you missing a using directive or an assembly reference?) (CS1061) (AuthorizationServer.Api) After adding its showing this error @Daniel – Amey Apr 13 '18 at 06:57
  • try: HttpConfigurationExtensions.MapHttpAttributeRoutes – Daniel Apr 13 '18 at 07:03
  • Error CS1061: 'HttpConfiguration' does not contain a definition for 'HttpConfigurationExtensions' and no extension method 'HttpConfigurationExtensions' accepting a first argument of type 'HttpConfiguration' could be found (are you missing a using directive or an assembly reference?) (CS1061) (AuthorizationServer.Api) . this error – Amey Apr 13 '18 at 07:05
  • same error as above coming .Error CS1061: 'HttpConfiguration' does not contain a definition for 'MapHttpAttributeRoutes' and no extension method 'MapHttpAttributeRoutes' accepting a first argument of type 'HttpConfiguration' could be found (are you missing a using directive or an assembly reference?) (CS1061) (AuthorizationServer.Api) – Amey Apr 13 '18 at 07:37
  • can you add all your namespaces that you are using ? – Amey Apr 13 '18 at 07:40
  • sorry @Amey. as i wrote it works on my machine (of course that doesn't help) may you try removing all of your usings. – Daniel Apr 13 '18 at 07:40
  • @Amey i have added my Owin References. May this helps. Added my startup.cs class. This has to be working! – Daniel Apr 13 '18 at 08:06
  • Having Same packages installed still same error on which os you Working ? – Amey Apr 13 '18 at 08:56
0

HttpConfiguration represents a configuration of HttpServer instances.

It is in the

System.Web.Http library

Nivas Pandian
  • 416
  • 1
  • 7
  • 17
  • i told that system.web.http error was rthere to resolve it i followed the above post as this lib is not available on mac – Amey Apr 13 '18 at 06:53