Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8408049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:32:09+00:00 2026-06-09T23:32:09+00:00

I wish to add an ASP.NET Web API to an ASP.NET MVC 4 Web

  • 0

I wish to add an ASP.NET Web API to an ASP.NET MVC 4 Web Application project, developed in Visual Studio 2012. Which steps must I perform to add a functioning Web API to the project? I’m aware that I need a controller deriving from ApiController, but that’s about all I know.

Let me know if I need to provide more details.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:32:11+00:00Added an answer on June 9, 2026 at 11:32 pm

    The steps I needed to perform were:

    1. Add reference to System.Web.Http.WebHost.
    2. Add App_Start\WebApiConfig.cs (see code snippet below).
    3. Import namespace System.Web.Http in Global.asax.cs.
    4. Call WebApiConfig.Register(GlobalConfiguration.Configuration) in MvcApplication.Application_Start() (in file Global.asax.cs), before registering the default Web Application route as that would otherwise take precedence.
    5. Add a controller deriving from System.Web.Http.ApiController.

    I could then learn enough from the tutorial (Your First ASP.NET Web API) to define my API controller.

    App_Start\WebApiConfig.cs:

    using System.Web.Http;
    
    class WebApiConfig
    {
        public static void Register(HttpConfiguration configuration)
        {
            configuration.Routes.MapHttpRoute("API Default", "api/{controller}/{id}",
                new { id = RouteParameter.Optional });
        }
    }
    

    Global.asax.cs:

    using System.Web.Http;
    
    ...
    
    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();
    
        RegisterGlobalFilters(GlobalFilters.Filters);
        WebApiConfig.Register(GlobalConfiguration.Configuration);
        RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);
    }
    

    Update 10.16.2015:

    Word has it, the NuGet package Microsoft.AspNet.WebApi must be installed for the above to work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an asp.net application which uses the web part framework to allow users
I am developing an ASP.Net MVC 3 web application. The app currently is connected
I wish to know the way to add ASP.NET (Machine_Name\IIS_IUSRS) to user role in
I'm working on a web application. One of my co-workers has written some asp.net
At my work we have an existing ASP.NET web application and are duplicating some
I have an ASP.NET web server and I wish to have a watchdog sending
We have an existing Firebird database which we wish to setup in an ASP.NET
I am tasked with creating a dashboard interface in our ASP.NET MVC 3 web
Using ASP.NET MVC 3 with C# I have a web page to display a
I have an ASP.NET MVC project in C# using Forms Authentication and Active Directory

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.