12.1: Star Setup

Install Microsoft.AspNet.WebApi

  1. Right click on the solution and go to Manage NuGet Packages.

  2. Click on Browse and type Microsoft.AspNet.WebApi.

  3. Select the Microsoft.AspNet.WebApi (not Core), check the Project box,and click Install.

  4. Click Ok and I Accept on the windows that come up.

  5. Close the Package Manager.

Add WebApiConfig.cs

  1. Go to ElevenNote.Web -> App_Start

  2. Right click and Add -> Class

  3. Name it WebApiConfig.cs

  4. Add this code:

     namespace ElevenNote.Web
     {
         public static class WebApiConfig
         {
             public static void Register()
             {
                 GlobalConfiguration
                     .Configure(
                         x =>
                         {
                             x
                                 .Formatters
                                 .JsonFormatter
                                 .SupportedMediaTypes
                                 .Add(new MediaTypeHeaderValue("text/html"));
    
                             x.MapHttpAttributeRoutes();
                         }
                     );
             }
         }
     }
  5. CTRL . to bring in the using statements

Global.asax.cs

  1. Go to ElevenNote.Web -> Global.asax -> Global.asax.cs

  2. On line 17, add WebApiConfig.Register();

             FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
             WebApiConfig.Register();
             RouteConfig.RegisterRoutes(RouteTable.Routes);

Next, we'll add an API just for the star functionality.

Last updated