Introduction To OWIN and KATANA in Visual Studio 2013 Preview

Introduction

In this growing world of Information Technology, every company must develop new enhancements for its establishment. Microsoft is doing the same thing for its establishment in the world of IT. Microsoft has released OWIN and KATANA with Visual Studio 2013 Preview. So, let me take you into the new world of .Net development with Open Web Interface (OWIN) and KATANA.

Brief

Developers have been using the ASP.NET Framework for over ten years. And numerous websites and services are running with the ASP.NET Framework development. As you know, web application development can be done by various technologies like ASP.NET MVC and ASP.NET WEB API, so cloud computing is the new world for web application development.

In that context, KATANA is the new project that provides the basic set of components for ASP.NET applications. The use of a KATANA Project enables flexibility, portability, and improved performance of web applications.

OWIN for .NET

Open Web Interface (OWIN) is a new methodology for defining interfaces. It is the new interface between web servers and web applications for achieving decoupled architecture. The .NET community members, inspired by the benefits of RACK (which provides a minimal interface among web servers supporting Ruby and Ruby frameworks) set out to create abstraction among web servers and framework components. There are the following two important goals for OWIN.

  • Easy development of components.
  • Easily ported among hosts and potentially entire operating systems.

The goal of OWIN is not to be the next development framework, it specifies the interaction among Web Servers and Web Frameworks. The NuGet Package for OWIN is available here.

There is one basic element in OWIN. It is an environment dictionary. It is responsible for storing all of the state necessary for processing an HTTP request and response. The syntax is.

IDictonary<string, object> 

Some of the dictionary keys for an HTTP Request are as follows.

Key Name Description
"owin.RequestBody" A Stream with the request body, if any. Stream.Null may be used in place of the request body as a placeholder
"owin.RequestMethod" A string containing the HTTP Request method of the request


KATANA for .NET

KATANA is responsible for building OWIN applications. It provides a flexible set of components for hosting Web Applications based on OWIN. The following are the goals of the KATANA project.

  • Portable: It includes all components that are available on the framework to the server and host. Now with this, the third-party frameworks can also seamlessly run on the server of Microsoft while Microsoft frameworks can potentially run on the third-party servers and hosts.
  • Flexible: You will see in many frameworks that multiple features are present in an application by default, but the KATANA project components are small, focused to the point and in it the component's control depends on the application developer.
  • Scalable: In it the substitutable components become available. The improved performance of the server introduces the improved performance of the OWIN apps.

Let's start to develop a Katana Project using the following procedure.

Step 1. Open Visual Studio 2013 Preview.

Visual Studio

Step 2. Enter your web application name.

Web application

Step 3. Select an Empty Project Template

 Empty Project

Step 4. Open the Package Manager Console and write the following command.

install-package Microsoft.Owin.Host.SystemWeb

 Package Manager

The installation of Microsoft.Owin.Host.SystemWeb will install a few dependencies. Microsoft. Owin is one of the dependencies that provides many methods and types to develop the OWIN applications.

Step 5. Add a class from the Solution Explorer and the name of the class is "Startup. cs".

 OWIN applications

Step 6. Open the Package Manager Console and write the following command.

Install-Package owin.extensions

Step 7. In your "Startup. cs" file write the following code.

using Owin;

namespace KatanaAppDemo
{
    public class Startup
    {
        public void Configuration(IAppBuilder MyKatanaApp)
        {
            MyKatanaApp.Run(content =>
            {
                content.Response.ContentType = "text/plain";
                return content.Response.WriteAsync("Welcome to the Demo of Katana Application");
            });
        }
    }
}

Step 8. Debug your application.

Debug

That's it.

Summary

In the preceding article, I introduced you to the new technology released with the Visual Studio 2013 Preview named OWIN and KATANA. I'll write my next article related to this technology. So, just go to your Visual Studio IDE and use the new experience of KATANA.

Thanks for reading my article and don't forget to comment.


Similar Articles