[[Open棟梁Project>http://opentouryo.osscons.jp/]] - [[マイクロソフト系技術情報 Wiki>http://techinfoofmicrosofttech.osscons.jp/]] -[[戻る>OWIN]] * 目次 [#p11234e4] #contents *概要 [#s2cb1789] -セルフホストやOWINミドルウェアを使用するために、パイプラインをOWIN化すること。 -既存のWebアプリケーションは、IIS(System.Web)を使用しているため、~ IISでホストするためのMicrosoft.Owin.Host.SystemWebを使用することになる。 -手順 --[[ホスティング ランタイムをインストールする。>#le7af00c]] --[[利用したい、OWINミドルウェアをインストールする。>#k436c439]] --[[Startupクラスを追加して、OWIN関連の設定を行う。>#n017a299]] *ホスティング ランタイム [#le7af00c] **IIS [#s102fafa] -IIS でホストするには、Microsoft.Owin.Host.SystemWebを使用する。 -NuGet で「Microsoft.Owin.Host.SystemWeb」をインストール。 install-package Microsoft.Owin.Host.SystemWeb -System.Webのパイプラインを[[OWIN]]のパイプラインに流すことができる。 -これにより、[[OWIN]]のミドルウェアをASP.NET Web Formsや、MVC 5でも使用できる。 **OwinHost.exe [#ibe04f08] -Katana の OwinHost.exe でホストするには、OwinHostを使用する。 -NuGet で「OwinHost」をインストール。 install-package OwinHost *[[OWIN]]ミドルウェア [#c666e4bd] **[[OWIN]]ミドルウェアのインストール [#k436c439] ***[[ASP.NET Identity]] [#x8cab528] ***[[ASP.NET SignalR]] [#x8cab528] **[[OWIN]]のパイプラインとミドルウェア作成 [#o8b46ad1] この「ミドルウェア」を自作すればパイプライン処理の挙動をカスタマイズできる。 -neue cc - OWINのパイプラインとMiddleware作成ガイド~ http://neue.cc/2014/01/06_442.html -neue cc - OWINの仕組みとOWIN上のフレームワーク(ミドルウェア)の作り方~ http://neue.cc/2014/05/13_473.html *Startupクラスの追加・登録 [#n017a299] [[OWIN]]パイプラインでミドルウェアをつなげ全体を処理する。 Startupクラスは、 -ホスティング ランタイムと -ミドルウェア を指定して使用できるようにする。 **共通 [#ye660630] **個別 [#ycfa2720] ***[[ASP.NET Identity]] [#p8d75cdd] ***[[ASP.NET SignalR]] [#d0df6846] ***[[ASP.NET Web API>ASP.NET Web API#rabd29db]] [#n4d2e2af] *既定のプロジェクト・テンプレートの調査 [#e4fddd28] **VS2010 [#ne9d5379] ***WebForms [#x12a00b7] 非[[OWIN]] ***MVC [#ob6f19b8] 非[[OWIN]] **VS2012 [#jcd3c4f6] ***WebForms [#n6268fca] -非[[OWIN]] -以下がサポートされた --BundleConfig --AuthConfig --RouteConfig -モジュール --Bundleには以下のモジュールが使用されている。 ---System.Web.Optimization --Authenticationには以下のモジュールが使用されている。 ---DotNetOpenAuth ---Microsoft.AspNet.Membership ---System.Web.Security.Membership --Routingには以下のモジュールが使用されている。 ---Microsoft.AspNet.FriendlyUrls ***MVC [#f8de12b5] -MVC3 --非[[OWIN]] --OAuthは未サポート -MVC4 --非[[OWIN]] --OAuth ---DotNetOpenAuth ---Microsoft.Web.WebPages.OAuth ---Webmatrix.Webdata.Websecurity ---System.Web.Security.Membership **VS2013 [#rea2d27d] [[OWIN]]化対応がなされた。 ***WebForms [#n6268fca] -認証対応テンプレート --組織アカウントの場合~ 恐らくWIFを使用してWS-Federationの認証連携を行う。 --個人アカウントの場合~ [[OWIN]]ミドルウェアである[[ASP.NET Identity]]~ を使用するために[[OWIN]]化対応がなされている。 -[[上記>#n6268fca]]から以下の変更が加えられた。 --個人アカウントの場合~ Authenticationは以下のモジュールに変更された。 ---Microsoft.AspNet.Identity.Core ---Microsoft.AspNet.Identity.Owin ---Microsoft.Owin.Security ***MVC [#f8de12b5] -変更内容は[[WebForms>#n6268fca]]と同様。 **VS2015 [#h8e67ca1] [[ASP.NET Core]]がサポートされた。 ***.NET Framework [#gee7e68a] 大枠、[[2013>#rea2d27d]]と同じ。 ***[[ASP.NET Core]] [#n563b16a] [[ASP.NET Core]]用のテンプレートはすべて[[OWIN]]化対応がなされている。 *参考 [#m5f3b2af] -Katana で Hello, world - miso_soup3 Blog~ http://miso-soup3.hateblo.jp/entry/2013/11/11/014258 -asp.net mvc - What is the new Startup.cs file for in Visual Studio 2013 projects? - Stack Overflow~ http://stackoverflow.com/questions/20034105/what-is-the-new-startup-cs-file-for-in-visual-studio-2013-projects -c# - Do I need a Global.asax.cs file at all if I'm using an OWIN Startup.cs class and move all configuration there? - Stack Overflow~ http://stackoverflow.com/questions/20168978/do-i-need-a-global-asax-cs-file-at-all-if-im-using-an-owin-startup-cs-class-and -OWIN Startup Class Detection | The ASP.NET Site~ https://www.asp.net/aspnet/overview/owin-and-katana/owin-startup-class-detection >Every OWIN Application has a startup class where you specify components for the application pipeline.~ There are different ways you can connect your startup class with the runtime,~ depending on the hosting model you choose (OwinHost, IIS, and IIS-Express).