Friday, January 2, 2015

I'm down to just one dead end now.

I started an online training on MVC5 today and it delved into OWIN and illuminated a solution for one of the two problems I mention here. One installs Microsoft.Owin.Hosting and Microsoft.Owin.Host.HttpListener from NuGet and one holds open the console application which one spins up like so:

using System;
using Microsoft.Owin.Hosting;
namespace MyKatana
{
   class Program
   {
      static void Main(string[] args)
      {
         string uri = "http://localhost:8080";
         using (WebApp.Start<Startup>(uri))
         {
            Console.WriteLine("Started!");
            Console.ReadKey();
            Console.WriteLine("Stopping!");
         }
      }
   }
}

 
 

It looks a lot like holding open a console application in a general sense, no? Yet, it's a bit different. To get this to work I also need a Startup class and it looks like this:

using Owin;
namespace MyKatana
{
   public class Startup
   {
      public void Configuration(IAppBuilder app)
      {
         app.Run(ctx =>
         {
            return ctx.Response.WriteAsync("Hello World!");
         });
      }
   }
}

 
 

Here are some dirty notes I typed up while listening to the training before I got to the solution above:

  • K. Scott Allen's MVC5 training at Pluralsight (http://www.pluralsight.com/courses/aspdotnet-mvc5-fundamentals)
  • membership and security model in MVC4 is now obsolete
  • Katana is a new project type for ASP.NET
  • a lot of MVC features have been moved into "OWIN middleware"
  • ASP.NET membership providers and simple membership providers are gone.
  • Identity componets which are interface-based provide some more flexibility and understand technologies like OAuth and OpenId and local accounts stored in SQL server databases
  • attribute routing
  • the Microsoft.AspNet.Mvc line item at packages.config should decry what version of MVC one is using
  • the video shows and upgrade from MVC4 to MVC5. The Target framework of the project gets moved from .NET Framework 4 to .NET Framework 4.5.1
  • go to "Manage NuGet Packages"
  • Microsoft.AspNet.Web.Helpers.Mvc has been renamed for MVC5 ... this needs to be uninstalled, then updates run, then the new version installed
  • one may "roll the dice" and pick "Update All" to bring all the packages up to date, or update oneseys and twoseys
  • ugh, the upgrade process is WAY painful
  • Microsoft.AspNet.WebHelpers in the new Microsoft.AspNet.Web.Helpers.Mvc
  • If you unload a .csproj file in Visual Studio you may edit it not unlike editing it in notepad... one then needs to Reload the project
  • particularly in cloud apps where you pay for every byte, there is a need to have things be light
  • Katana is Microsoft's implementation of an open standard named OWIN (Open Web Interface for .NET)
  • web frameworks and web servers should be decoupled
  • MONO is the open source implemenation of .NET
  • System.Web is tied to ASP.NET and IIS as kinda fat instead of fast
  • MVC5 has a reference to Microsoft.Owin and Microsoft.Owin.Security and Owin
  • create a Console Application for Katana to listen to and process HTTP request
  • install-package -IncludePrerelease Microsoft.Owin.Hosting ...to the console app
  • install-package -IncludePrerelease Microsoft.Owin.Host.HttpListener
  • using Owin namespace one may add an IAppBuilder app
  • .Environment in IAppBuilder has a dictionary of things like cookies and headers and server variables, etc.
  • install-package -IncludePrerelease Microsoft.Owin.Diagnostics ...has the welcome page
  • an IDictionary of string,object is an environment
  • as you add extensions with other NuGet Owin packages they will typically add things you may dot off to from an IAppBuilder

No comments:

Post a Comment