# Adding ASP.NET Web API Support to an Existing Visual Studio ASP.NET MVC Project

> Add ASP.NET Web API support to an existing MVC project by installing the Microsoft.AspNet.WebApi NuGet package, creating a WebApiConfig class with route mappings, and registering it in Global.asax before the default MVC route. This enables the Web.TextControl MVC HtmlHelper.

- **Author:** Bjoern Meyer
- **Published:** 2015-12-12
- **Modified:** 2026-03-05
- **Description:** Add ASP.NET Web API support to an existing MVC project by installing the Microsoft.AspNet.WebApi NuGet package, creating a WebApiConfig class with route mappings, and registering it in Global.asax before the default MVC route. This enables the Web.TextControl MVC HtmlHelper.
- **2 min read** (363 words)
- **Tags:**
  - HTML5
  - WebApi
- **Web URL:** https://www.textcontrol.com/blog/2015/12/12/adding-aspnet-web-api-support-to-an-existing-visual-studio-aspnet-mvc-project/
- **LLMs URL:** https://www.textcontrol.com/blog/2015/12/12/adding-aspnet-web-api-support-to-an-existing-visual-studio-aspnet-mvc-project/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2015/12/12/adding-aspnet-web-api-support-to-an-existing-visual-studio-aspnet-mvc-project/llms-full.txt

---

*TXTextControl.Web.MVC* is using the ASP.NET Web API framework to synchronize the edited document with the server in order to render the output in a true WYSIWYG manner.

From [Microsoft MSDN](https://msdn.microsoft.com/en-us/library/hh833994%28v=vs.108%29.aspx):

> ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework.

In our MVC tutorial, we describe how to create a new ASP.NET MVC project with Web API support. But very often, TX Text Control is added to existing MVC projects. This tutorial shows how to add ASP.NET Web API support to an existing MVC project.

1. Click *Manage NuGet Packages...* from the *Project* main menu.
2. Set the *Package source* to *nuget.org* and search for *Microsoft.AspNet.WebApi*. Select the package *Microsoft.AspNet.WebApi* and click on *Install*. Accept the license for all 4 packages by clicking *I Accept*.
    
    ![Adding ASP.NET Web API support to an existing ASP.NET MVC project](https://s1-www.textcontrol.com/assets/dist/blog/2015/12/12/a/assets/visualstudio_nuget_webapi.webp "Adding ASP.NET Web API support to an existing ASP.NET MVC project")
3. In the *Solution Explorer*, select the folder *App\_Start* and choose *Add New Item...* from the *Project* main menu. Select *Class* as the new item and name it *WebApiConfig.cs*. Confirm with *Add*.
    
    Add the following code to the newly created config file and import the namespace *System.Web.Http*:
    
    ```
    using System.Web.Http;
    
    public class WebApiConfig
    {
      public static void Register(HttpConfiguration configuration)
      {
        configuration.Routes.MapHttpRoute("API Default", "api/{controller}/{id}",
          new { id = RouteParameter.Optional });
      }
    }
    ```
4. Import the namespace *System.Web.Http* in *Global.asax.cs*.
5. In the file *Global.asax.cs*, call *GlobalConfiguration.Configure(WebApiConfig.Register);* in *MvcApplication.Application\_Start()* before registering the default web application route:
    
    ```
    protected void Application_Start()
    {
        GlobalConfiguration.Configure(WebApiConfig.Register);
        AreaRegistration.RegisterAllAreas();
        RouteConfig.RegisterRoutes(RouteTable.Routes);
    }
    ```

That's it - you added Web API support to your ASP.NET MVC project. Now, you can use the *TXTextControl.Web.MVC* HtmlHelper in your web application.

---

## About Bjoern Meyer

As CEO, Bjoern is the visionary behind our strategic direction and business development, bridging the gap between our customers and engineering teams. His deep passion for coding and web technologies drives the creation of innovative products. If you're at a tech conference, be sure to stop by our booth - you'll most likely meet Bjoern in person. With an advanced graduate degree (Dipl. Inf.) in Computer Science, specializing in AI, from the University of Bremen, Bjoern brings significant expertise to his role. In his spare time, Bjoern enjoys running, paragliding, mountain biking, and playing the piano.

- [LinkedIn](https://www.linkedin.com/in/bjoernmeyer/)
- [X](https://x.com/txbjoern)
- [GitHub](https://github.com/bjoerntx)

---

## Related Posts

- [Securing WebSocket Connections in ASP.NET Core using Sec WebSocket Protocol Header](https://www.textcontrol.com/blog/2025/11/20/securing-websocket-connections-in-aspnet-core-using-sec-websocket-protocol-header/llms.txt)
- [Detect Toggle Button Changes Using a MutationObserver](https://www.textcontrol.com/blog/2021/11/11/detect-toggle-button-changes-using-a-mutationobserver/llms.txt)
- [Angular: Deploying the Backend TCP Service Separately](https://www.textcontrol.com/blog/2020/10/09/angular-deploying-the-backend-tcp-service-separately/llms.txt)
- [Implementing Conditional Table Cell Colors with MailMerge](https://www.textcontrol.com/blog/2020/10/08/implementing-conditional-table-cell-colors-with-mailmerge/llms.txt)
- [Adding a WebSocket Security Middleware to ASP.NET Core Web Applications](https://www.textcontrol.com/blog/2020/05/28/adding-a-websocket-security-middleware-to-aspnet-core/llms.txt)
- [Securing the WebSocketHandler Endpoint in ASP.NET](https://www.textcontrol.com/blog/2020/05/28/securing-the-websockethandler-endpoint-in-aspnet/llms.txt)
- [Creating an ASP.NET MVC DocumentViewer Application With Razor](https://www.textcontrol.com/blog/2020/01/01/creating-an-aspnet-mvc-documentviewer-application-with-razor/llms.txt)
- [Creating an ASP.NET MVC Application With Razor](https://www.textcontrol.com/blog/2020/01/01/creating-an-aspnet-mvc-application-with-razor/llms.txt)
- [Creating Your First ASP.NET Reporting Application](https://www.textcontrol.com/blog/2020/01/01/creating-your-first-aspnet-reporting-application/llms.txt)
- [Creating an ASP.NET Web Forms AJAX Application](https://www.textcontrol.com/blog/2020/01/01/creating-an-aspnet-web-forms-ajax-application/llms.txt)
- [Automatically Reconnect to the Server and Recover the Document](https://www.textcontrol.com/blog/2019/09/05/automatically-reconnect-to-the-server-and-recover-the-document/llms.txt)
- [Deploying the MVC HTML5 Editor to Azure App Services](https://www.textcontrol.com/blog/2018/04/06/deploying-the-mvc-html5-editor-to-azure-app-services/llms.txt)
- [JavaScript API: Working with Merge Fields](https://www.textcontrol.com/blog/2018/03/05/javascript-api-working-with-merge-fields/llms.txt)
- [Technology Preview: Embeddable HTML Widget to integrate Document Editing to Angular, React and other Frameworks](https://www.textcontrol.com/blog/2018/03/01/embeddable-html-widget-for-all-frameworks/llms.txt)
- [Best Practices for Adding Ribbon Tabs, Groups and Buttons to the TXTextControl.Web Ribbon Bar](https://www.textcontrol.com/blog/2017/12/21/best-practices-for-adding-ribbon-content-to-txtextcontrol-web/llms.txt)
- [X15: Adding MS Word Compatible Fields and Form Elements to TXTextControl.Web](https://www.textcontrol.com/blog/2017/12/20/using-ms-word-form-elements-in-txtextcontrol-web/llms.txt)
- [X15: Inserting Client-Side Images using JavaScript](https://www.textcontrol.com/blog/2017/12/14/inserting-client-side-images-using-javascript/llms.txt)
- [Embedding TXTextControl.Web in non-.NET Framework applications like .NET Core and AngularJS](https://www.textcontrol.com/blog/2017/10/23/embedding-txtextcontrol/llms.txt)
- [Sneak Peek X15: Contextual Chart Ribbon Tabs](https://www.textcontrol.com/blog/2017/07/20/sneak-peek-x15-contextual-chart-ribbon-tabs/llms.txt)
- [Sneak Peek X15: Copy to Local Clipboard Support in ASP.NET Version](https://www.textcontrol.com/blog/2017/07/13/sneak-peek-x15-copy-to-local-clipboard-support-in-aspnet-version/llms.txt)
- [Sneak Peek X15: Custom Field Overlays in HTML5-based Text Control](https://www.textcontrol.com/blog/2017/06/21/sneak-peek-x15-custom-field-overlays-in-html5-based-text-control/llms.txt)
- [New ASP.NET MVC DocumentViewer Rolled out to the ReportingCloud Portal](https://www.textcontrol.com/blog/2017/04/22/new-aspnet-mvc-documentviewer-rolled-out-to-the-reportingcloud-portal/llms.txt)
- [Updated MVC Sample: Loading Files from the Backstage Menu](https://www.textcontrol.com/blog/2017/04/20/updated-mvc-sample-loading-files-from-the-backstage-menu/llms.txt)
- [ASP.NET MVC: Implementing a Simplistic, Custom Button Bar](https://www.textcontrol.com/blog/2017/03/13/aspnet-mvc-implementing-a-simplistic-custom-button-bar/llms.txt)
- [ASP.NET MVC: Adding Protected Sections to Documents](https://www.textcontrol.com/blog/2017/03/01/aspnet-mvc-adding-protected-sections-to-documents/llms.txt)
