Introduction

In this article I will use the "Superscribe.Owin" package in the ASP.NET Web API. We use the package for determine what the web framework contributes. Superscribe is a module for the router handler. It is a way to map between the media types and serialiser.

Now for an example.

Step 1

Create an application as in the following:

Select Web Application

Step 2

Install a package as in the following:

Step 3

Now install the Superscribe.Owin Package through Nuget Manager.

Install Superscribe.Owin Package

Step 4

There is a class named "Startup.cs".

Add the following code to it:

  1. using Owin;
  2. using Superscribe.Owin;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Web;
  7. namespace SuperOwin
  8. {
  9. public class Startup
  10. {
  11. public void Configuration(IAppBuilder ibuild)
  12. {
  13. var Con = new SuperscribeOwinConfig();
  14. Con.MediaTypeHandlers.Add(
  15. "text/html",
  16. new MediaTypeHandler { Write = (rslt, o) => rslt.WriteAsync(o.ToString()) });
  17. ibuild.UseSuperscribeModules(Con);
  18. }
  19. }
  20. }

Step 5

Add a new class as in the following:

create Class

Add the folowing code:

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using Superscribe.Owin;
  6. namespace SuperOwin
  7. {
  8. public class Hello: SuperscribeOwinModule
  9. {
  10. public Hello()
  11. {
  12. this.Get["/"] = _ => "This is the example of Superscribe Owin:";
  13. }
  14. }
  15. }

Step 6

Now in the Web.config file we ensure that it handles the OWIN request:

  1. <appSettings>
  2. <add key="owin:HandleAllRequests" value="true" />
  3. <add key="owin:SetCurrentDirectory" value="true" />
  4. </appSettings>

Step 7

Now execute the application:

Output