This is a transcript of a video published on the blog's YouTube channel except for one section. That section was omitted to keep the video under 5 minutes. This may be helpful for fellow developers who cannot view videos during their work.
Before discussing about PnP SDKs, please note that the first preference to interact with SharePoint Online should always be Graph SDK. That is the official stand from Microsoft. In case Graph API doesn't have the feature, go for SharePoint APIs or CSOM APIs. There are 2 different SDKs or nuget packages to interact with CSOM API from .Net applications. PnP.Framework and PnP.Core to name the nugets. Today we are talking about these 2 PnP SDKs what SDK we should choose and why one over the other?
As per the documentation the PnP.Core is the successor of PnP.Framework. In that sense PnP.Core should be our clear preference. One benefit they are advertising is that it can seamlessly switch between the modern Graph API and old SharePoint CSOM APIs. That will hide the API complexities from the developer and the developer needs to learn only PnP.Core. But there are more reasons than that to choose PnP.Core.
Number of lines
First of all PnP.Core requires less number of lines to achieve a task. Take the example of Getting the title of the web.
The left side is PnP.Framework code and the right side show PnP.Core. We can clearly see that the PnP.Core works with one less line. Compare this in an enterprise application with tens of thousands of lines.
Ease of use
Now let us look at the ease of use in achieving a use case. The example we are taking is the renaming of a folder in the document library. PnP.Core has a direct Rename method to do that. But PnP.Framework uses the move method with the new name.
Support for Dependency injection
The PnP.Core SDK has out-of-the-box dependency injection support. If we are using PnP.Framework, we need to write extra code to get the .net core model dependency injection.
Size of the request payload
The PnP.Framework uses one particular URL almost always. It is _vti_bin/client.svc/ProcessQuery. This is the Fiddler screenshot of PnP.Framework making HTTP call to get a folder by relative Url. It uses HTTP POST to get data instead of HTTP GET. The request payload is XML format.Luckily response is in JSON. The XML requires more bytes than JSON for sending the same information. The different operations are achieved by changing the method attribute in the request payload.
Now let us see how the same use case is done by PnP.Core. As we can see it uses HTTP GET with user friendly URL. No request payload at all. The response payload is relatively smaller than the PnP.Framework
Here is the side-by-side comparison between the two when querying for a folder by its relative Url. Left is PnP.Framework and right side is the PnP.Core.
Logging
Now coming to the logging aspects, PnP.Core is already following the .Net programming model and honoring the ILogger API. By adding the required configuration in the appsettings.json file we can get the logs into the required destination.
Observability
Observability is important to run a production workload. Tools such as Azure Application Insights normally log the URLs and their HTTP verbs. That will help us to understand the system behavior and also to troubleshoot issues. We have already seen that the Url is used by the PnP.Framework is mostly the same. Adding to that, it always uses HTTP POST with parameters to distinguish the operation which makes. We cannot distinguish the operation type by the HTTP verbs.
Error handling
In a normal web system, when an error happens it will return respective HTTP status codes. Never Http 200. Look a the fiddler trace when querying with non existing folder path from PnP.Framework. it always returns HTTP 200. In case it errors out, the error message will be inside. Production observability systems can never detect errors like this and proactively alert the dev team.
Otherside, PnP.Core error out with proper HTTP status code. In case the folder URL is not present, we get HTTP 404 back, and will be handled properly by the production monitoring systems.
Contribution to Library
The PnP libraries are open-source and maintained by the community. Microsoft is not giving any warranty or support for these libraries. In case we end up facing an issue and need to get fixed quickly we need to fix ourselves and give a pull request.
Look at the source code of PnP.Core and PnP.Framework. The PnP.Core is relatively simple to understand. Meaning easy for us to fix the bugs in that library. It simply prepares the Url uses an internal method to execute that Url and returns the result.
Can we completely avoid PnP.Framework?
Not really. The PnP.Core is not a feature-complete SDK. There are features that are not available in PnP.Core.. In such situations, we need to use PnP.Framework. One place they are telling PnP.Core will eventually replace PnP.Framework. However, when a feature request was created to bridge the gap in CreateCopyJobs-related tasks, they informed PnP.Core is never going to implement that feature. In such situations we need PnP.Framework forever.
This relates somewhat to a post in this blog about the dilemma of choosing Net SDK to interact with SharePoint". Since there are multiple .Net SDKs the selection of one is tricky. Now think about multiple APIs to interact with. For simplicity, we are now concerned about only SharePoint Online by avoiding SharePoint services on-premises.
This post tries to visually represent the APIs and corresponding .Net SDK to interact with SharePoint Online.
Generated using PlantUML. Click on the image to get svc where the links are navigatable.
The traditional .Net Framework web applications hosted in IIS will restart automatically when the configuration changes. The configuration is mainly stored in web.config and the restart will be performed by the IIS by watching the files. .Net Core and continuing .Net has the same feature to monitor the config changes and get it reflected in the application. At least in .Net the application will not be entirely restarting but the values will be available to consumers of IConfigration.
Problem
Ideally, if the consumer class of IConfiguration is not caching the values, they all get the updated values. But in large applications, there may be chances that some classes may be caching the values into member variables. Then upon config change, some classes work properly some do not. Eventually, this led to bug and production war rooms.
Having proper code reviews educate developers etc...is the solution to the problem. But as a debugger how to identify that a config changed in between which was the potential reason for the subsequent defect?
Solution
Ideally, there should be the below section in the config that logs the configuration changes.
Last year, there was a post about moving to Heroku from firebase as firebase mandated credit card even for the free tier. Also, that post explained the issues in giving credit cards for freemium services.
As far as I am concerned, the main usage of this free server-side execution mechanism is to host a YouTube API proxy that will be giving data about my YouTube videos.
Why API proxy? My Jamstack Hugo-based personal website (https://joymononline.in) is showing the list of recent youtube videos in my channels. As part of building the site, it makes a call to this API proxy where the API keys and throttling details are hidden.
The YouTube-proxy-API is coded in Node.JS so it can ideally be hosted anywhere supporting the Node.JS execution environment. Normally Node.JS is one of the first technology any hosting platform will support.
If we google 'Heroku alternative for free hosting' we get a handful of options. Netlify, Back4app, and Vercel to name a few. They all come with reasonable limits that are way higher than simple needs.
Render.com
Instead of trying the above list, I thought of trying something else called Render.com. The experience was very smooth. The code in the repo worked without any changes after hosting to render.com. Below is the link
Often when we develop we will end up in situations where we need to simulate the real scenario by mocking the dependencies. It may be databases, Web APIs, or container images. There was a separate post on mock container images that echo HTTP.
Problem
There are scenarios where we may not be having the opportunity to run containers to expose the mock Web APIs. This post about handling such scenarios
Solutions
There are many solutions to address this.
Hosting Web API from our machine
We don't need to code from scratch. Just search in GitHub and we can get many. Simply clone and run.
Using internet-hosted mock Web APIs
This works if our development environment has access to the internet. There are paid as well as freemium services. One such freemium service is Beeceptor.
Please note this post is not sponsored by Beeceptor also the author is not at all affiliated to the service. Their service saved some time today hence this post.
This post is advised to read after the previous post about modernizing the .Net Framework console app to use .Net Core Programming model without changing the runtime. It helps to slowly migrate large monolith .Net Framework apps into .Net.
This post is about slowly migrating legacy WebAPI applications in the same way. ie adding DI using ServiceCollection and ILogger without changing the .Net Framework runtime.
Sample source code
This time there is no video tutorial. Let us look at the actual code itself.
Below goes the areas that need to be changed to get dependency injection from the Controller classes themselves.
Creating the ServiceCollection
This is obviously the first step in doing the DI.
Hope the code is explanatory if we have some basic idea about the .Net Core programming model. The Get() returns the ServiceProvider after configuring ServiceCollection.
Overriding DependencyResolver
It's easy to see the code first.
We just added our own DependencyResolver. Next, let us see what is in that new resolver class.
This facilitates the creation of objects as and when asked by the ASP.Net WebAPI framework.
ILogger Support
Nothing special to be done. The ConfigureServices() in ServiceProviderFactory class does it.
.Net 6.0 introduced the minimal API model for WebAPIs. That is highly reducing the amount of boilerplate code to be used to run WebAPIs. All actions can be included in a single file. This post is not to explain the wow factor of the Minimal API model but to give some tips to use ILogger in minimal APIs.
This is the second video in the Kubernetes series. Actually, when I started vlogging, I had decided that I will make short videos of max 5 minutes. But unfortunately, I was not able to stick to that. Here onwards I am planning to stick with my time limit.
What is new?
We have to configure applications based on the environment it runs. It is not different for containerized applications running in Kubernetes. This video is showing how to configure the environment variables for the containers.
It uses an ASP.Net Core WebAPI application that returns the environment variable name when invoked with the name. It uses .Net 5 and basic YAML to deploy to Kubernetes that is running on Docker Desktop using WSL2 as a backend.
This post mainly contains the notes that I used to create a video. The video talks about hosting ASP.Net WebAPI into Kubernetes. The API can be accessible from the host machine using http://localhost:<port>/. The aim is to show simple hosting in Kubernetes that runs using Docker Desktop.
It is advised to watch the video to get more clarity.
Dev environment
Please refer to the previous post about setting up Docker Desktop and K8s environment. Along with that, it is required to have Visual Studio 2019 with docker container ASP.Net tools installed.
Source code
This post is not about creating a new visual studio project and enable the K8s support. Instead, download the sample from the below location
The question is clear from the title itself. Let us put the environment details to get more clarity.
Problem
It is an ASP.Net Core 2.1 Web API application that runs on .Net Framework 4.8. It has its own controller classes in its assembly. In addition to that, there are some controller classes in other projects that need to be added via the nuget package manager. Assuming they are not conflicting.
With ASP.Net Core 2.1, there is no need to complicate things as long as we are inheriting the controller class from the ControllerBase class and decorate it with [ApiController].
We have to make sure the other assembly that contains the controller classes is available in /bin folder of the hosting application. If not in the /bin folder it's reachable to be loaded into the application.
Sample
It's not complete by just telling it is simple. A working solution can be downloaded from GitHub. It has a readme.md file to get started.
Points to note
When we have multiple controller assemblies, we need to make sure the controllers are not conflicting with each other.
APIController v/s ControllerBase
Now there may be a question arising. What is the difference between these APIController v/s ControllerBase classes for ASP.Net WebAPI? Tune for a dedicated blog post on it. Wait it's something that happened years back. Why should there be one more blog post? The answer is right there in StackOverflow. Below are the main points.
ASP.Net WebAPI and ASP.Net MVC merged in ASP.Net Core.
ASP.Net Core provides a new base class called ControllerBase for developing WebAPIs. Use that where ever possible as that is the future. Even .Net 5 is providing ControllerBase as the way to develop WebAPIs.
If we are stuck with APIController class, ASP.Net Core is providing a shim named WebAPICompactShim. Use that ONLY during the migration time.
This is an index of things which needs to be checked, for performance optimization of a simple ASP.Net + Angular application. The simple application refers to application which read and write to SQL Server. If the application uses some other data store, still the points about other aspects are valid.
The details of each item would be either a link to posts in this blog or link to other resources. If someone is struggling to find where to start or struck on an optimization exercise,hope these questions will light a bulb in their brain. Sorry to say that it is very difficult to find an algorithm which applies every performance optimizations.
Browser side
Do we need to support desktop and mobile browsers?
Any possibility to avoid Internet Explorer and support only modern browsers:)
Do we have separate mobile site with URL or same site is controlled via bootstrap or similar display technique
Static assets
Are those cached? If not can we cache?
If those are cached what is the cache expiry?
If those are cached how its done? cache-control or Expires header? Is the cache really working?
Is the server properly returning http 304?
Are they minified and bundled?
Are the images optimized to have small foot print?
Are they served from CDN?
Angular best practices applied?
If it is AngularJS, what is the feasibility to upgrade to Angular
The network
DNS and routing
Hows the DNS resolved to IP?
Is the application available public or accessed only via enterprise intranet?
What is the network connection band width between clients and server? also between web servers and database server(s)
Network devices
CDN
Any option for warming up cache?
Security / Application Gateways which open packets and scan for attacks.
What is the time needed for security inspections? Is it fast, if we bye pass gateway for testing?
Network load-balancer
Do we have load balancer? Are we reached the height of optimization and need scale out or scale up? In Azure, the best practice is to use LB as the machines gets patches and restarts periodically. Also follow the best practices to group machines so that all of those will not be restarted same time.
What is the algorithm used for load balancing?
Do we have sticky session need?
Common
Do we have logs available from these devices?
Are the logs enough to confirm that the backing web server is taking time to respond?
Web Server machine
Does the requirement of project is practical to the server? eg: One quad core, 8GB VM may never support 100,000 concurrent users even if its a simple company static web site
Is the machine / hosting infrastructure in Azure or any cloud? If so do all the best practices followed and coded by considering cloud principles such as retry pattern?
What is the status of CPU, Memory, Network etc.. during load test or busy hour?
Are we logging any custom field which are big in size?
Are the extra logging such as failed request tracking enabled?
During a load test of busy session
If we go to IIS worker process screen are we able to see many requests pending?
What is the http queue length performance counter shows ?
Are we able to identify one or sub set of requests taking high chunk of processing time other than rest of requests? This can be done by analyzing IIS logs.
Static assets - Kind of repetition from previous section.
Are they cached properly?
Are we using ASP.Net Bundling or compile time bundled? Are they served in minimized form
Can we increase cache expiry?
Protocols
Any possibility to leverage http/2, if not done?
Is it using web sockets?
Authentication
Is it using windows authentication? If so NTML or Kerberos? Kerberos is recommended for better performance
AppPool Recycling
What is the AppPool recycling settings?
Is the recycling causing delay?
Any ways to run mock requests so that the cache is populated before real user hit application?
Throttling / Limiting
What is the MaxConnection Setting and other IIS level throttling?
Are there any performance counter showing connections getting queued and rejected?
Timeouts
Is there any manual test and load test attempted by reducing the timeouts to lowest possible settings? Some times high timeouts cause some requests to occupy entire system resources
Payload
Does the http compression enabled
ASP.Net Application
ASP.Net pipeline till our code
What are the throttling settings at different level?
Are there any custom HttpModules which may reduce performance? Any unwanted modules?
Our code
Are there anything which can be cached instead of going every time to database? eg: any reference tables which change only by deployment.
Are there any retries happening and succeeding after lot of attempts? Try reducing retry count to 3.
Are there static variable usage and any potential for lock contention and memory leaks?
Are the locks applied to lowest possible code section?
JSON optimization
Can the property names be shortened?
Are the default values serialized into JSON?
Are we doing any HTML rendering at server and returning as JSON property? Any possibility to make application as pure client rendered SPA?
Do we have high amount of reflection?
.Net General
Are there high amount of GC collections? This can be found from analyzing performance counters?
What is the fragmentation level in LOH?
Can we do NGEN?
Any memory leaks in the application? eg: open connections, unwanted static things which may hold objects?
Database
Does the applications logs showing that the queries are taking time?
Does the SQL setup with possible best practices? eg: temp db, flags, connection limiting etc...
Are there any subset of SPs always slow?
Mind map
Finally, there is a mind map created using PlantUML for easy reference. Since this is kept textual in GitHub and rendered on demand, this would be living document than the post.
Developing PoCs (Proof of Concepts) or samples to prove some approach or technology is suitable for our project is some every software engineer does as part of their job. Also if something goes wrong with existing systems in production we often create a sample to isolate and reproduce the problem to analyze further. If the role is of Architect, they have to involve more into these research kind of activities. Please note that create these PoCs are slightly different from prototyping as prototype is more towards visualizing the concept in the initial time only.
The goal of PoC if it is to troubleshoot an issue is to create it to the closest way possible to mimic the actual application in trouble. If the issue is production the time will be limited to create app from scratch. When we say closest it should be closest in terms of the technology, threading model, security etc...
Problem
If it is windows application of console applications, it is easy to develop a PoC and run the same way the original application runs. Even if original application is triggered in the context of a different user configured from windows task scheduler or similar, we can still mimic it. But most of the applications are web apps now a days. If we want to reproduce an issue of Web App, it would be difficult if we create a windows console app unless we run the console application using the same service account of app pool which runs the web app. But still the threading model and all will be different. If we want to develop the PoC as web application, it may take some more time than a simple console application which adds delay.
One possible solution
So the best way is to develop WebAPI and host it using the same app pool of original application. Provided there are permissions to host. Suppose we have permissions to host, the next thing is the easiness to test using WebAPI alone. If we have to develop UI for that it would take more time. So what is the solution?
Swashbuckle
Enter Swashbuckle after the long introduction which help us to render UI for the available WebAPI methods. This helps us to test the WebAPIs from a simple UI dynamically generated by it.
Since there are so many links out there which explains how to use it, lets follow the DRY principle. Links below on how to setup Swashbuckle into the WebAPI.
There would be so many different views on solving the original problem of creating PoCs. Feel free to comment your technique of rapidly creating PoCs to mimic the real application.
ReST is highly considered as architectural pattern for integrating systems. It mainly uses APIs
point to resource and do operation on those. The URL often follows a cleaner hierarchical path pattern without much key value pairs than conventional key value pair based URL schemes. People often follow the ReST based URL format for APIs but not widely accepted for web sites.
This post aims to investigate on bringing this ReST based URL schemes to web sites similar to APIs.
Why should I do create web sites as ReSTful URLs
The same benefit of ReST based API URLs applies here as well. The URL will be easy to remember. It is easy to have separation of concerns. New features can be totally implemented separately. using their own area / virtual directories. No need to mix with existing screens even it they are related. Simple and short URLs than lengthy story telling URLs.
eg: www.mycompany.com/employeelist.aspx?empId=1 can be easily represented via
www.mycompany.com/employees/1
Why there are not much web sites following ReSTful pattern
One reason could be the difficulty to follow the pattern. If it is product company the development team will get more freedom to select URLs. Again if the product owners don't know what is ReST and the advantages they may influence the URL pattern. In the other side the consulting industry is heavily driven by client demands. Though regular clients may not ask for particular URLs, semi technical clients may ask.
Some tips for ReSTful web site URLS
Below are some tips to design web site URLs in resource oriented way
No operation
oriented screens
The screens should be pointing to resources to display those. For example the below URL displays the employee resource.
www.mycompany.com/employees/1
Lists and details
screens
If the URLs display the resource how to edit them? Which screen to edit those resources? The better way is to use lists and details mechanism.
If we display the resources in a list those can be edited in the same list itself and save using a button. Here the single page application (SPA) concept helps us than navigating to an edit page.
Circular navigation
If the resources have circular relation the navigation may also becomes circular.
For example, the employee page may show the department where he belongs to as hyper link. Clicing that will navigate to dept page where it lists the employees in that dept including the manager. Going to the manager page may display employees under him and clicking on the same employee's link there will end up in same employees page where we started.
Multiple navigation paths
Similarly there would be multiple navigation paths to reach one resource. For example the home page of company may show the departments and various project it is doing currently. Navigating to department as well as project may end up in same employee page.
A powerful search experience to navigate
If a resource is buried under the hierarchy, it would be difficult to find it without multiple clicks. So better to have a search mechanism where the resource can be searched and navigated on clicking the associated URLs.
There are still debates going on regarding whether Github is a developer's resume or not. Whatever happens it is good to show the list of GitHub projects in a software engineer's personal site to whom he/she is contributing to.
Integrating Github API to www.JoymonOnline.in
Below is the diagram shows how I have integrated GitHub into my personal site.
www.JoymonOnline.in is a web site
Most of us know the difference between web site and web app. Here in this case we are dealing with a web site where the HTML is generated at server side and send to client. Client browser is supposed to just render the markup given by web server.
How the GitHub API looks like
Its just a URL. More specifically ReST urls which points to resources. Below is one example API url. This gives details about the repository joyful-visualstudio. Just copy paste the url into browser address bar and hit enter. The data will be displayed.
Coming to technical programming aspects. Here in this site the API is called using WebClient class. This is a simple class in .Net framework which can be used to deal with web sites and web APIs.
Authentication / Security
If the request is not authenticated, we can perform read operations. But there is a limit in such calls. That limit is based on the IP address from where the call originates. In this case the call originates from ASP.Net code of http://joymononline.in web site. The site is hosted in shared hosting plan. It means there will be other sites in same server machine. They may call GitHub without authentication and from GitHub point all originate from same IP and it limits.
To get rid of that problem we can authenticate the requests with token. The simple way is to obtain the token from GitHub and keep in the site and transfer via header. The header name used is 'Authorization'. Now the limit is per token, its high limit and no need to worry about shared hosting.
Securing API token
Make sure the token is not public. In JoymonOnline where source is hosted in public repository in Github itself, token is not visible. Its inserted during the deployment time from AppVeyor CI solution.
.Net Client SDK
GitHub also has client sdk to make the interaction easier. If we are using client SDK we don't need to worry about low level http related WebClient class.
This is a continuation of older posts in TypeScripting AngularJS 1.x series. Here lets see, how we can use the $http service in typed way using TypeScript.
The API
The main TypeScript type, we need to understand here, is the ng.IHttpService. This is the equivalent type of $http object. This comes via the AngularJS typedefinition file which can be downloaded from nuget. The another type is the ng.IHttpPromiseCallbackArg<T>. This is the container which is returned via the Then() method.
Sample
Before coding the client side, lets see the server side code which is going to be called from browser.
This action method takes id as string and return the country / region details. Anonymous return type has 3 properties which are all strings.
If we host this inside IIS using web application named testapi, we can invoke the API by browsing the below url.
class Country {
DisplayName:string;
Currency:string;
CurrencySymbol:string;constructor(){}}
Casting in TypeScript
The first confusion will happen on the casting of http result to Country object. Where we are telling the return type is Country in TypeScript?
Here is the difference between the real type safe languages such as C# / Java and TypeScript. In TypeScript since its finally running as JavaScript, we can accept values in any type, if that looks similar to the incoming object. Here the output of web request has properties which are matching to properties of Country class so those are just copied. If there are no matching properties still this code compiles but at run-time the properties of result object will be undefined. No exception in any case.
We can make it more TypeSafe by adding generic type to the get method.
The get() accepts an optional ng.IRequestShortcutConfig object too. Lets see how that can be passed into the method in type safe way.
var config: ng.IRequestShortcutConfig ={};
config.cache =true;this.http
.get<Country>('http://localhost/testapi/home/getcountrymetadata/cn',config).then((result: ng.IHttpPromiseCallbackArg<Country>)=>{this.Countries.push(result.data);});
Interesting thing here in TypeScript is, we don't need to create the implementation class to use the interface. This again is feasible, since it runs in JavaScript engine where there is no type safety. After the compilation everything is JavaScript. We know that, there is nothing called interface in JavaScript runtime.
The {} creates an object just like in JavaScript. After that we can set required properties. Since we have declared the variable as ng.IRequestShortcutConfig, we will get intellisense on the config object. We don't need to remember all the properties, which we need to do in pure JavaScript programming.
Here config.cache.= true tells the $http, to cache the requests using Angular JS cache factory.
This is the age of APIs in computer science. To be more specific web APIs. Don't get confused with the specific technology of .Net Web API. Any methods or resources which are exposed via URL in a structure is an API. From our apps we can call them to do achieve the functionality.
Resources are now a days exposed via ReST protocol and the format is JSON. It works well with JavaScript. But when coming to .Net world, its little difficult to keep the JSON as is in our app. Often we need to convert those resources into entity classes. Creating entity class for each API response is a tricky tasks. It puts more time to complete the API integration tasks. Often after using one API for months we may need to switch to another API providing same service. At that time we need to rewrite it. Creating classes to get exact replica of response is really difficult to manage.
But its always suggested to have entity classes which are for our application regardless of the API we are using. As soon as we got the response from the web API, we should convert the response to our model and that should go on from that point on wards.
Dynamic object to hold JSON
In the beginning people were programming without type safety. Then the strong typed languages were introduced and everybody went behind that. Now its the time everybody again going to dynamic typing. May be its because of JavaScript's success.
VB always gave us the option to have dynamic typing. But in C# its introduced with .Net 4.0. The dynamic keyword is introduced to denote the variables which are not type safe. In other words a type which we don't know at compile time, what it is going to contain. Kind of key value store / dictionary.
Enough theory. Below is the code to convert a GitHub API response. The API url is
JavaScriptSerializer is a .Net framework class. We don't need to add any dependency to third parties. There are other .Net libraries which are helping to convert JSON to dynamic object but those will add unwanted dependencies. Hope this is self explanatory.
Important thing to note here is the usage of dynamic. Do not ever return dynamic to outer world. This method should hide the complexities of getting the project from GitHub. The consumers of this method then don't need to change when the logic of GitHub API interaction changes.
More details about usage in real application can be seen in this file.
WebAPI can be hosted via 2 ways. The traditional way using HttpSelfHostServer and the new OWIN based hosted. Below is an attempt to compare both techniques.
API Controller
Below is the controller class I am going to host using both the hosting techniques.
Differences between HttpSelfHostServer and OWIN Hosting
In HttpSelfHostServer we can see most of the things as configurable. But in OWIN, its by convention.