<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Vincent Leung .NET Tech Clips</title>
	<atom:link href="https://vincenthomedev.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://vincenthomedev.wordpress.com</link>
	<description>The latest tech clips from the .NET community</description>
	<lastBuildDate>Wed, 06 Jul 2016 00:06:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<site xmlns="com-wordpress:feed-additions:1">1494855</site><cloud domain='vincenthomedev.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>https://secure.gravatar.com/blavatar/fb2e0614d4c1e8abf97c9688112de06d61e761e10fdc72f8525fb71bb9ab9dc4?s=96&#038;d=https%3A%2F%2Fs0.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Vincent Leung .NET Tech Clips</title>
		<link>https://vincenthomedev.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="https://vincenthomedev.wordpress.com/osd.xml" title="Vincent Leung .NET Tech Clips" />
	<atom:link rel='hub' href='https://vincenthomedev.wordpress.com/?pushpress=hub'/>
	<item>
		<title>ASP.NET Core &#038; .NET Core 1.0</title>
		<link>https://vincenthomedev.wordpress.com/2016/07/04/asp-net-core-net-core-1-0/</link>
					<comments>https://vincenthomedev.wordpress.com/2016/07/04/asp-net-core-net-core-1-0/#respond</comments>
		
		<dc:creator><![CDATA[Vincent Leung]]></dc:creator>
		<pubDate>Mon, 04 Jul 2016 18:58:08 +0000</pubDate>
				<category><![CDATA[.NET Core]]></category>
		<category><![CDATA[ASP.NET Core]]></category>
		<guid isPermaLink="false">http://vincenthomedev.wordpress.com/?p=2424</guid>

					<description><![CDATA[Install: https://www.microsoft.com/net/core#windows .NET Core Guide: https://docs.microsoft.com/en-us/dotnet/articles/core/index Tutorial: https://docs.microsoft.com/en-us/dotnet/articles/core/tutorials/index Samples: https://github.com/dotnet/core/ Documentation: https://docs.asp.net/en/latest/index.html&#160; ASP.NET Core Guide: https://docs.asp.net/en/latest/ OAuth2 Authentication LinkedIn]]></description>
										<content:encoded><![CDATA[<ul>
<li>Install: <a title="https://www.microsoft.com/net/core#windows" href="https://www.microsoft.com/net/core#windows">https://www.microsoft.com/net/core#windows</a>  </li>
<li>.NET Core Guide: <a title="https://docs.microsoft.com/en-us/dotnet/articles/core/index" href="https://docs.microsoft.com/en-us/dotnet/articles/core/index">https://docs.microsoft.com/en-us/dotnet/articles/core/index</a>  </li>
<li>Tutorial: <a title="https://docs.microsoft.com/en-us/dotnet/articles/core/tutorials/index" href="https://docs.microsoft.com/en-us/dotnet/articles/core/tutorials/index">https://docs.microsoft.com/en-us/dotnet/articles/core/tutorials/index</a>  </li>
<li>Samples: <a title="https://github.com/dotnet/core/" href="https://github.com/dotnet/core/">https://github.com/dotnet/core/</a>  </li>
<li>Documentation: <a title="https://docs.asp.net/en/latest/index.html" href="https://docs.asp.net/en/latest/index.html">https://docs.asp.net/en/latest/index.html</a>&nbsp; </li>
<li>ASP.NET Core Guide: <a title="https://docs.asp.net/en/latest/" href="https://docs.asp.net/en/latest/">https://docs.asp.net/en/latest/</a> </li>
</ul>
<p>OAuth2 Authentication</p>
<ul>
<li><a href="https://auth0.com/blog/2016/06/13/authenticating-a-user-with-linkedin-in-aspnet-core/?utm_source=DNK-155622&amp;utm_medium=DNK-155622&amp;utm_content=DNK-155622&amp;utm_campaign=DNK-155622">LinkedIn</a></li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://vincenthomedev.wordpress.com/2016/07/04/asp-net-core-net-core-1-0/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2424</post-id>
		<media:content url="https://1.gravatar.com/avatar/17028b12b45ce1b4a47f9306bd89aba97368840bf8fe4c0c6645a355498b9b20?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">Vincent Leung</media:title>
		</media:content>
	</item>
		<item>
		<title>Angular 1.3 new features</title>
		<link>https://vincenthomedev.wordpress.com/2015/02/26/angular-1-3-new-features/</link>
					<comments>https://vincenthomedev.wordpress.com/2015/02/26/angular-1-3-new-features/#respond</comments>
		
		<dc:creator><![CDATA[Vincent Leung]]></dc:creator>
		<pubDate>Fri, 27 Feb 2015 01:00:00 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<guid isPermaLink="false">http://vincenthomedev.wordpress.com/?p=2417</guid>

					<description><![CDATA[$validators app.directive('validateInteger', function () { var REGEX = /^\-?\d+$/; return { require: 'ngModel', link: function (scope, element, attrs, ctrl) { ctrl.$validators.integer = function (modelValue, viewValue) { if (REGEX.test(viewValue)) { return true } return false; }; } }; }); Async $validators app.directive('validateUsername', function ($q, userService) { return { require: 'ngModel', link: function (scope, element, attrs, ctrl) [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a href="https://vincenthomedev.wordpress.com/wp-content/uploads/2015/02/image.png"><img style="margin:0;display:inline;" title="image" src="https://vincenthomedev.wordpress.com/wp-content/uploads/2015/02/image_thumb.png?w=398&#038;h=120" alt="image" width="398" height="120" /></a></p>
<ul>
<li><a href="http://blog.thoughtram.io/angularjs/2015/01/11/exploring-angular-1.3-validators-pipeline.html">$validators</a></li>
</ul>
<pre><code>app.directive('validateInteger', function () {

  var REGEX = /^\-?\d+$/;

  return {
    require: 'ngModel',
    link: function (scope, element, attrs, ctrl) {

      ctrl.$validators.integer = function (modelValue, viewValue) {

        if (REGEX.test(viewValue)) {
          return true
        }
        return false;
      };
    }
  };
});</code></pre>
<ul>
<li>Async $validators
<pre><code>app.directive('validateUsername', function ($q, userService) {

  return {
    require: 'ngModel',
    link: function (scope, element, attrs, ctrl) {

      ctrl.$asyncValidators.username = function (modelValue, viewValue) {
        return $q(function (resolve, reject) {
          userService.checkValidity(viewValue).then(function () {
              resolve();
            }, function () {
              reject();
            });
        });
      };
    }
  };
});</code></pre>
</li>
</ul>
<p>Using it:</p>
<pre><code>&lt;form name="myForm"&gt;
  &lt;input type="text" name="username" validate-username&gt;
  &lt;p ng-if="myForm.username.$pending"&gt;Validating user name...&lt;/p&gt;
&lt;/form&gt;</code></pre>
<ul>
<li><a href="http://blog.thoughtram.io/angularjs/2015/01/23/exploring-angular-1.3-ngMessages.html">ngMessages &amp; ngMessage</a>
<pre><code>&lt;ng-messages for="loginForm.password.$error"&gt;
  &lt;ng-message when="required"&gt;...&lt;/ng-message&gt;
  &lt;ng-message when="minlength"&gt;...&lt;/ng-message&gt;
  &lt;ng-message when="pattern"&gt;...&lt;/ng-message&gt;
  &lt;ng-message when="validator4"&gt;...&lt;/ng-message&gt;
  &lt;ng-message when="validator5"&gt;...&lt;/ng-message&gt;
&lt;/ng-messages&gt;</code></pre>
</li>
</ul>
<blockquote>
<pre><code>&lt;script type="script/ng-template" id="required-message"&gt;
  &lt;ng-message when="required"&gt;
    This field is required!
  &lt;/ng-messages&gt;
&lt;/script&gt;

&lt;ng-messages ng-messages-include="required-message" for="loginForm.password.$error"&gt;
  ...
&lt;/ng-messages&gt;

&lt;!-- somewhere else --&gt;
&lt;ng-messages ng-messages-include="required-message" for="otherForm.field.$error"&gt;
  ...
&lt;/ng-messages&gt;</code></pre>
</blockquote>
<ul>
<li><a href="http://blog.thoughtram.io/angularjs/2015/01/02/exploring-angular-1.3-bindToController.html">bindToController for Directive</a>
<ul>
<li>For Directives having an isolated scope with properties to be bound to a controller.
<pre><code>app.directive('someDirective', function () {
  return {
    scope: {
      name: '='
    },
    controller: function () {
      this.name = 'Pascal';
    },
    controllerAs: 'ctrl',
    bindToController: true,
    template: '&lt;div&gt;{{ctrl.name}}&lt;/div&gt;'
  };
});</code></pre>
</li>
</ul>
</li>
<li><a href="http://blog.thoughtram.io/angularjs/2014/10/19/exploring-angular-1.3-ng-model-options.html">ng-model-options</a>
<ul>
<li>UpdateOn
<pre><code>&lt;input 
  type="text" 
  ng-model="name" 
  ng-model-options="{ updateOn: 'default blur' }"&gt;</code></pre>
</li>
<li>debounce
<pre><code>&lt;input 
  type="search" 
  ng-model="searchQuery" 
  ng-model-options="{ updateOn: 'default blur', debounce: { 'default': 300, 'blur': 0 } }"&gt;</code></pre>
</li>
</ul>
</li>
<li><a href="http://blog.thoughtram.io/angularjs/2014/10/19/exploring-angular-1.3-ng-model-options.html">$rollbackViewValue</a>&lt;form name=&#8221;userForm&#8221;&gt;<br />
&lt;input type=&#8221;text&#8221; name=&#8221;userName&#8221;<br />
ng-model=&#8221;name&#8221;<br />
ng-model-options=&#8221;{ updateOn: &#8216;blur&#8217; }&#8221;<br />
ng-keyup=&#8221;<strong>cancel($event)</strong>&#8221; /&gt;<br />
&lt;/form&gt;</p>
<p>$scope.cancel = function (e) {<br />
if (e.keyCode == 27) {   // 27: ESC key<br />
$scope.userForm.userName.<strong>$rollbackViewValue()</strong>;<br />
}</li>
<li><a href="http://blog.thoughtram.io/angularjs/2014/10/14/exploring-angular-1.3-one-time-bindings.html">One way bindings</a>
<ul>
<li>&lt;p&gt;Hello {{<strong>::name</strong>}}&lt;/p&gt;</li>
<li>&lt;li ng-repeat=”item in <strong>::items</strong>”&gt;{{item.name}}&lt;/li&gt;</li>
</ul>
</li>
<li><a href="http://blog.thoughtram.io/angularjs/2014/12/22/exploring-angular-1.3-disabling-debug-info.html">Disable Debug Info</a></li>
<li><a href="http://blog.thoughtram.io/angularjs/2015/01/14/exploring-angular-1.3-speed-up-with-applyAsync.html">$applyAsync</a></li>
<li><a href="http://blog.thoughtram.io/angularjs/2014/12/18/exploring-angular-1.3-es6-style-promises.html">ES6 Style Promises</a></li>
<li><a href="http://blog.thoughtram.io/angularjs/2014/11/19/exploring-angular-1.3-stateful-filters.html">Stateful Filters</a></li>
<li><a href="http://blog.thoughtram.io/angularjs/2014/11/06/exploring-angular-1.3-angular-hint.html">Angular Hint</a></li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://vincenthomedev.wordpress.com/2015/02/26/angular-1-3-new-features/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2417</post-id>
		<media:content url="https://1.gravatar.com/avatar/17028b12b45ce1b4a47f9306bd89aba97368840bf8fe4c0c6645a355498b9b20?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">Vincent Leung</media:title>
		</media:content>

		<media:content url="https://vincenthomedev.wordpress.com/wp-content/uploads/2015/02/image_thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Bootstrap Cheat Sheet</title>
		<link>https://vincenthomedev.wordpress.com/2014/12/21/bootstrap-cheat-sheet/</link>
					<comments>https://vincenthomedev.wordpress.com/2014/12/21/bootstrap-cheat-sheet/#respond</comments>
		
		<dc:creator><![CDATA[Vincent Leung]]></dc:creator>
		<pubDate>Sun, 21 Dec 2014 19:06:10 +0000</pubDate>
				<category><![CDATA[Cheatsheet]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[HTML5]]></category>
		<guid isPermaLink="false">http://vincenthomedev.wordpress.com/?p=2415</guid>

					<description><![CDATA[http://www.cheatography.com/masonjo/cheat-sheets/bootstrap/pdf/]]></description>
										<content:encoded><![CDATA[<p><a href="https://vincenthomedev.wordpress.com/wp-content/uploads/2014/12/image17.png"><img title="image" style="margin:0;display:inline;" alt="image" src="https://vincenthomedev.wordpress.com/wp-content/uploads/2014/12/image_thumb17.png?w=480&#038;h=247" width="480" height="247"/></a></p>
<p><a title="http://www.cheatography.com/masonjo/cheat-sheets/bootstrap/pdf/" href="http://www.cheatography.com/masonjo/cheat-sheets/bootstrap/pdf/">http://www.cheatography.com/masonjo/cheat-sheets/bootstrap/pdf/</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://vincenthomedev.wordpress.com/2014/12/21/bootstrap-cheat-sheet/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2415</post-id>
		<media:content url="https://1.gravatar.com/avatar/17028b12b45ce1b4a47f9306bd89aba97368840bf8fe4c0c6645a355498b9b20?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">Vincent Leung</media:title>
		</media:content>

		<media:content url="https://vincenthomedev.wordpress.com/wp-content/uploads/2014/12/image_thumb17.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Design Pattern Cheat Sheet</title>
		<link>https://vincenthomedev.wordpress.com/2014/12/21/design-pattern-cheat-sheet/</link>
					<comments>https://vincenthomedev.wordpress.com/2014/12/21/design-pattern-cheat-sheet/#respond</comments>
		
		<dc:creator><![CDATA[Vincent Leung]]></dc:creator>
		<pubDate>Sun, 21 Dec 2014 18:52:14 +0000</pubDate>
				<category><![CDATA[Architecture]]></category>
		<category><![CDATA[Cheatsheet]]></category>
		<category><![CDATA[Design]]></category>
		<guid isPermaLink="false">http://vincenthomedev.wordpress.com/?p=2409</guid>

					<description><![CDATA[http://www.cheat-sheets.org/saved-copy/designpatternscard1.pdf]]></description>
										<content:encoded><![CDATA[<p><a href="https://vincenthomedev.wordpress.com/wp-content/uploads/2014/12/image16.png"><img title="image" style="margin:0;display:inline;" alt="image" src="https://vincenthomedev.wordpress.com/wp-content/uploads/2014/12/image_thumb16.png?w=387&#038;h=300" width="387" height="300"/></a></p>
<p><a title="http://www.cheat-sheets.org/saved-copy/designpatternscard1.pdf" href="http://www.cheat-sheets.org/saved-copy/designpatternscard1.pdf">http://www.cheat-sheets.org/saved-copy/designpatternscard1.pdf</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://vincenthomedev.wordpress.com/2014/12/21/design-pattern-cheat-sheet/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2409</post-id>
		<media:content url="https://1.gravatar.com/avatar/17028b12b45ce1b4a47f9306bd89aba97368840bf8fe4c0c6645a355498b9b20?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">Vincent Leung</media:title>
		</media:content>

		<media:content url="https://vincenthomedev.wordpress.com/wp-content/uploads/2014/12/image_thumb16.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Underscore.js Cheatsheet</title>
		<link>https://vincenthomedev.wordpress.com/2014/12/21/underscore-js-cheatsheet/</link>
					<comments>https://vincenthomedev.wordpress.com/2014/12/21/underscore-js-cheatsheet/#respond</comments>
		
		<dc:creator><![CDATA[Vincent Leung]]></dc:creator>
		<pubDate>Sun, 21 Dec 2014 18:37:03 +0000</pubDate>
				<category><![CDATA[Cheatsheet]]></category>
		<category><![CDATA[JavaScript]]></category>
		<guid isPermaLink="false">http://vincenthomedev.wordpress.com/?p=2405</guid>

					<description><![CDATA[http://f.cl.ly/items/093o0l2Y3u130y0W0c0x/underscore-cheat-sheet.pdf]]></description>
										<content:encoded><![CDATA[<p><a href="https://vincenthomedev.wordpress.com/wp-content/uploads/2014/12/image15.png"><img loading="lazy" title="image" style="margin:0;display:inline;" alt="image" src="https://vincenthomedev.wordpress.com/wp-content/uploads/2014/12/image_thumb15.png?w=432&#038;h=328" width="432" height="328"/></a></p>
<p><a title="http://f.cl.ly/items/093o0l2Y3u130y0W0c0x/underscore-cheat-sheet.pdf" href="http://f.cl.ly/items/093o0l2Y3u130y0W0c0x/underscore-cheat-sheet.pdf">http://f.cl.ly/items/093o0l2Y3u130y0W0c0x/underscore-cheat-sheet.pdf</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://vincenthomedev.wordpress.com/2014/12/21/underscore-js-cheatsheet/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2405</post-id>
		<media:content url="https://1.gravatar.com/avatar/17028b12b45ce1b4a47f9306bd89aba97368840bf8fe4c0c6645a355498b9b20?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">Vincent Leung</media:title>
		</media:content>

		<media:content url="https://vincenthomedev.wordpress.com/wp-content/uploads/2014/12/image_thumb15.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Secure ASP.NET WebAPI 2 using Azure Active Directory AD with ADAL JS</title>
		<link>https://vincenthomedev.wordpress.com/2014/12/21/secure-asp-net-webapi-2-using-azure-active-directory-ad-with-adal-js/</link>
					<comments>https://vincenthomedev.wordpress.com/2014/12/21/secure-asp-net-webapi-2-using-azure-active-directory-ad-with-adal-js/#respond</comments>
		
		<dc:creator><![CDATA[Vincent Leung]]></dc:creator>
		<pubDate>Sun, 21 Dec 2014 18:27:11 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Azure]]></category>
		<category><![CDATA[WebAPI]]></category>
		<guid isPermaLink="false">http://vincenthomedev.wordpress.com/?p=2401</guid>

					<description><![CDATA[&#160; What we will use OAuth 2.0 middleware ASP.NET WebAPI 2.2 Authentication Project Template: Organization Account Azure Active Directory SPA Azure AD Authentication Library (ADAL) for javascript &#160; Create a WebAPI Project with Organizational Accounts Cloud – Single Organization Domain/AD Tenant – yourorganization.onmicrosoft.com Access Level – Single Sign On (i.e. lets the directory issue tokens [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>&nbsp;</p>
<h6>What we will use</h6>
<ul>
<li>OAuth 2.0 middleware  </li>
<li>ASP.NET WebAPI 2.2  </li>
<li>Authentication Project Template: Organization Account  </li>
<li>Azure Active Directory  </li>
<li>SPA  </li>
<li>Azure AD Authentication Library (ADAL) for javascript</li>
<h6><font face="Helvetica"></font>&nbsp;</h6>
</ul>
<h6>Create a WebAPI Project with Organizational Accounts</h6>
<ul>
<li>Cloud – Single Organization  </li>
<li>Domain/AD Tenant – <em>yourorganization</em>.onmicrosoft.com  </li>
<li>Access Level – Single Sign On (i.e. lets the directory issue tokens for your application)
<ul>
<li>Other access level include “Read/ReadWrite Directory data” using the REST Graph API</li>
</ul>
</li>
</ul>
<h6>Setup:</h6>
<p>At Startup.Auth.cs</p>
<blockquote>
<p><font size="2"><em>// ida:Tenant – yourorganization.onmicrosoft.com<br />// ida:Audience – </em></font><a href="https://yourorganization.onmicrosoft.com/MyWebAPIProjectName"><font size="2"><em>https://yourorganization.onmicrosoft.com/MyWebAPIProjectName</em></font></a><br /><font size="2"><em>app.UseWindowsAzureActiveDirectoryBearerAuthentication(<br />new WindowsAzureActiveDirectoryBearerAuthenticationOptions<br />{<br />Tenant = ConfigurationManager.AppSettings[“ida:Tenant”],<br />TokenValidationParameters = new TokenValidationParameters {<br />ValidAudience = ConfigurationManager.AppSettings[“ida:Audience”]<br />},<br />});</em></font></p>
</blockquote>
<p>Publish the WebAPI app.</p>
<h6>Register the SPA App with Azure AD</h6>
<ul>
<li>Go to Active Directory –&gt; Application  </li>
<li>Add Application (Web Client)  </li>
<li>Add Sign-On Url </li>
<li>Add App ID Url </li>
<li>Add Redirect URI</li>
<li>Enable OAuth2 Implicit Grant – refer to sample app <a href="https://github.com/AzureADSamples/SinglePageApp-DotNet">readme</a>.</li>
<li>Configure the App.js tenant, clientId with web.config ‘s ida:Tenant &amp; ida:Audience respecitively.</li>
</ul>
<p>p.s. As of Dec. 20 2014. Looks like the sample is still not ready for hosting the client app in Azure. i.e. the client app will only work when running localhost. </p>
<p>Reference: <a title="https://github.com/AzureADSamples/SinglePageApp-DotNet" href="https://github.com/AzureADSamples/SinglePageApp-DotNet">https://github.com/AzureADSamples/SinglePageApp-DotNet</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://vincenthomedev.wordpress.com/2014/12/21/secure-asp-net-webapi-2-using-azure-active-directory-ad-with-adal-js/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2401</post-id>
		<media:content url="https://1.gravatar.com/avatar/17028b12b45ce1b4a47f9306bd89aba97368840bf8fe4c0c6645a355498b9b20?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">Vincent Leung</media:title>
		</media:content>
	</item>
		<item>
		<title>Secure ASP.NET WebAPI 2 using Azure Active Directory AD with ADAL .NET</title>
		<link>https://vincenthomedev.wordpress.com/2014/12/18/secure-asp-net-webapi-2-using-azure-active-directory-ad-with-oauth-2/</link>
					<comments>https://vincenthomedev.wordpress.com/2014/12/18/secure-asp-net-webapi-2-using-azure-active-directory-ad-with-oauth-2/#comments</comments>
		
		<dc:creator><![CDATA[Vincent Leung]]></dc:creator>
		<pubDate>Thu, 18 Dec 2014 21:34:52 +0000</pubDate>
				<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Azure]]></category>
		<category><![CDATA[OAuth]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[WebAPI]]></category>
		<guid isPermaLink="false">http://vincenthomedev.wordpress.com/?p=2395</guid>

					<description><![CDATA[What we will use OAuth 2.0 middleware ASP.NET WebAPI 2.2 Authentication Project Template: Organization Account Azure Active Directory Native Application e.g. Windows Form App Azure AD Authentication Library (ADAL) for .NET 2.x The ‘Authority’ / ‘Identity Provider’ – Azure AD Resources often offload most of the authentication functions to an external services provider, commonly known [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a href="https://vincenthomedev.wordpress.com/wp-content/uploads/2014/12/image14.png"><img loading="lazy" style="margin:0;display:inline;" title="image" src="https://vincenthomedev.wordpress.com/wp-content/uploads/2014/12/image_thumb14.png?w=558&#038;h=106" alt="image" width="558" height="106" /></a></p>
<h4>What we will use</h4>
<ul>
<li>OAuth 2.0 middleware</li>
<li>ASP.NET WebAPI 2.2</li>
<li>Authentication Project Template: Organization Account</li>
<li>Azure Active Directory</li>
<li>Native Application e.g. Windows Form App</li>
<li>Azure AD Authentication Library (ADAL) for .NET 2.x</li>
</ul>
<h4>The ‘Authority’ / ‘Identity Provider’ – Azure AD</h4>
<p>Resources often offload most of the authentication functions to an external services provider, commonly known as an authority or an identity provider.</p>
<p>With those functions out of the way, the only authentication task left is to verify that authentication succeeded at the authority. This typically involves examining a security token, a data fragment issued by an authority to a caller upon successful authentication.</p>
<p>Security tokens are usually crafted according to a specific format, <span style="background-color:#ffff00;">digitally signed by a key that will unequivocally identify the issuing authority, and contain some data that uniquely ties the token to the target resource</span>. When the resource receives a request, it looks for an accompanying token. If it finds one that meets the required validation attributes, the caller is authenticated.</p>
<h4>Create a WebAPI Project with Organizational Accounts</h4>
<ul>
<li>Cloud – Single Organization</li>
<li>Domain/AD Tenant – <em><span style="background-color:#ffff00;">yourorganization</span></em>.onmicrosoft.com</li>
<li>Access Level – Single Sign On (i.e. lets the directory issue tokens for your application)
<ul>
<li>Other access level include “Read/ReadWrite Directory data” using the REST Graph API</li>
</ul>
</li>
</ul>
<h5>Setup:</h5>
<p>In <strong>Startup.Auth.cs</strong></p>
<blockquote><p><span style="font-size:small;background-color:#ffff00;"><em>// ida:Tenant &#8211; yourorganization.onmicrosoft.com<br />
// ida:Audience &#8211; </em></span><a href="https://yourorganization.onmicrosoft.com/MyWebAPIProjectName"><span style="font-size:small;background-color:#ffff00;"><em>https://yourorganization.onmicrosoft.com/MyWebAPIProjectName</em></span></a><br />
<span style="font-size:small;"><em>app.UseWindowsAzureActiveDirectoryBearerAuthentication(<br />
new WindowsAzureActiveDirectoryBearerAuthenticationOptions<br />
{<br />
Tenant = ConfigurationManager.AppSettings[&#8220;ida:Tenant&#8221;],<br />
TokenValidationParameters = new TokenValidationParameters {<br />
ValidAudience = ConfigurationManager.AppSettings[&#8220;ida:Audience&#8221;]<br />
},<br />
});</em></span></p></blockquote>
<h5>Publish the WebAPI App.</h5>
<p>The app.Use* naming convention adds a middleware implementation to the OWIN pipeline. The added middleware inspects the incoming request to see if the <span style="background-color:#ffff00;">HTTP header Authorization</span> contains a security token. If it finds a token, it validates the issuing authority, the integrity, expiration date.</p>
<p>If the token looks good, the middleware projects its content in a principal. If it isn’t, sends back an error code.</p>
<p>If there’s no token, the middleware simply lets the call go through without creating a principal (i.e. anonymous). [Authorize] decides whether the request should be served or access denied.</p>
<p>The <span style="background-color:#ffff00;">Audience</span> value is the <span style="background-color:#ffff00;">identifier</span> by which the Web API is known to Windows Azure AD. <span style="background-color:#ffff00;">Any tokens carrying a different Audience are meant for another resource and should be rejected</span>.</p>
<p>The middleware uses that <span style="background-color:#ffff00;">Tenant</span> property value to read all the other properties (such as which key should be used to verify the token’s signatures) that determine the validity of a token.</p>
<h4>Register the Native Client App with Azure AD</h4>
<ul>
<li>Go to Active Directory –&gt; Application</li>
<li>Add Application (Web Client / Native Client)</li>
<li>Add Redirect URI</li>
</ul>
<p>More AD configuration for the client app</p>
<ul>
<li>Click the Configure tab</li>
<li>Copy the Client ID</li>
<li>Add/Select  the target WebAPI server application and then hit save</li>
</ul>
<h4>Create Native Client App</h4>
<ul>
<li>Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory</li>
</ul>
<blockquote><p><span style="font-size:small;"><em>// Get token<br />
AuthenticationContext ac = new AuthenticationContext(<br />
<span style="background-color:#ffff00;">// Azure -&gt; AD -&gt; Domain -&gt;  </span></em></span><a href="https://login.windows.net/"><span style="font-size:small;background-color:#ffff00;"><em>https://login.windows.net/</em></span></a><span style="font-size:small;"><em><span style="background-color:#ffff00;"> + AD tenant/domain name</span><br />
&#8220;</em></span><a href="https://login.windows.net/yourorganization.onmicrosoft.com&quot;);"><span style="font-size:small;"><em>https://login.windows.net/<span style="background-color:#ffff00;">yourorganization.onmicrosoft.com</span>&#8220;);</em></span></a><br />
<span style="font-size:small;"><em>AuthenticationResult ar =<br />
ac.AcquireToken(<br />
<span style="background-color:#ffff00;">// WebAPIApp web.config &#8216;s ida:Audience</span><br />
&#8220;</em></span><a href="https://yourorganization.onmicrosoft.com/MyWebAPI&quot;"><span style="font-size:small;"><em>https://yourorganization.onmicrosoft.com/MyWebAPI&#8221;</em></span></a><span style="font-size:small;"><em>,<br />
<span style="background-color:#ffff00;">// Azure -&gt; AD -&gt; Application -&gt; clientapp&#8217;s CLIENT ID</span><br />
&#8220;8a39841b-7dcc-4b92-b546-a0799bae312c&#8221;,<br />
<span style="background-color:#ffff00;">// Azure -&gt; AD -&gt; Application -&gt; clientapp&#8217;s REDIRECT URIS</span><br />
new Uri(&#8220;</em></span><a href="https://mynativeclient&quot;));"><span style="font-size:small;"><em>https://mynativeclient&#8221;));</em></span></a></p></blockquote>
<blockquote><p><span style="font-size:small;"><em>// Call Web API<br />
string authHeader = ar.CreateAuthorizationHeader();<br />
HttpClient client = new HttpClient();<br />
HttpRequestMessage request = new HttpRequestMessage(<br />
HttpMethod.Get, &#8220;</em></span><a href="https://mywebapi.azurewebsites.net/Api/Values&quot;);"><span style="font-size:small;"><em>https://mywebapi.azurewebsites.net/Api/Values&#8221;);</em></span></a><br />
<span style="font-size:small;"><em>request.Headers.TryAddWithoutValidation(&#8220;Authorization&#8221;, authHeader);<br />
HttpResponseMessage response = await client.SendAsync(request);<br />
string responseString = await response.Content.ReadAsStringAsync();<br />
MessageBox.Show(responseString);</em></span></p></blockquote>
<p>When I provide the credentials of any valid user from my directory tenant, I get a token back. The subsequent code presents the token to the Web API in the request headers. The security middleware validates it. Because all validation parameters are a match, it sends back HTTP status code 200 with the results.</p>
<p>If click the button again. You’ll get a token back right away, without being prompted. That’s because ADAL has a built-in token cache that keeps track of the tokens. It even takes care of silently refreshing expired tokens whenever possible.</p>
<p>Reference: <a title="http://msdn.microsoft.com/en-us/magazine/dn463788.aspx" href="http://msdn.microsoft.com/en-us/magazine/dn463788.aspx">http://msdn.microsoft.com/en-us/magazine/dn463788.aspx</a></p>
<p><a title="https://vincenthomedev.wordpress.com/2014/11/30/azure-active-directory-for-mvc-webapi/" href="https://vincenthomedev.wordpress.com/2014/11/30/azure-active-directory-for-mvc-webapi/">https://vincenthomedev.wordpress.com/2014/11/30/azure-active-directory-for-mvc-webapi/</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://vincenthomedev.wordpress.com/2014/12/18/secure-asp-net-webapi-2-using-azure-active-directory-ad-with-oauth-2/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2395</post-id>
		<media:content url="https://1.gravatar.com/avatar/17028b12b45ce1b4a47f9306bd89aba97368840bf8fe4c0c6645a355498b9b20?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">Vincent Leung</media:title>
		</media:content>

		<media:content url="https://vincenthomedev.wordpress.com/wp-content/uploads/2014/12/image_thumb14.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Find In Database Objects</title>
		<link>https://vincenthomedev.wordpress.com/2014/12/18/find-in-database-objects/</link>
					<comments>https://vincenthomedev.wordpress.com/2014/12/18/find-in-database-objects/#respond</comments>
		
		<dc:creator><![CDATA[Vincent Leung]]></dc:creator>
		<pubDate>Thu, 18 Dec 2014 13:00:00 +0000</pubDate>
				<category><![CDATA[Database]]></category>
		<guid isPermaLink="false">http://vincenthomedev.wordpress.com/?p=2071</guid>

					<description><![CDATA[It searches the text of triggers, UDFs, stored procedures and views for a particular substring, returning the name and type of those database objects that match. DECLARE @Search varchar(255) SET @Search='[10.10.100.50]' SELECT DISTINCT o.name AS Object_Name,o.type_desc FROM sys.sql_modules        m INNER JOIN sys.objects  o ON m.object_id=o.object_id WHERE m.definition Like &#8216;%&#8217;+@Search+&#8217;%&#8217; ORDER BY 2,1]]></description>
										<content:encoded><![CDATA[<pre><span style="font-family:Verdana;">It searches the text of triggers, UDFs, stored procedures and views for a particular substring, </span></pre>
<pre><span style="font-family:Verdana;">returning the name and type of those database objects that match. </span></pre>
<pre><code>DECLARE @Search varchar(255)
SET @Search='[10.10.100.50]'</code></pre>
<p>SELECT DISTINCT<br />
o.name AS Object_Name,o.type_desc<br />
FROM sys.sql_modules        m<br />
INNER JOIN sys.objects  o ON m.object_id=o.object_id<br />
WHERE m.definition Like &#8216;%&#8217;+@Search+&#8217;%&#8217;<br />
ORDER BY 2,1</p>
]]></content:encoded>
					
					<wfw:commentRss>https://vincenthomedev.wordpress.com/2014/12/18/find-in-database-objects/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2071</post-id>
		<media:content url="https://1.gravatar.com/avatar/17028b12b45ce1b4a47f9306bd89aba97368840bf8fe4c0c6645a355498b9b20?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">Vincent Leung</media:title>
		</media:content>
	</item>
		<item>
		<title>Font Awesome &#8211; Get Started</title>
		<link>https://vincenthomedev.wordpress.com/2014/12/17/font-awesome-get-started/</link>
					<comments>https://vincenthomedev.wordpress.com/2014/12/17/font-awesome-get-started/#respond</comments>
		
		<dc:creator><![CDATA[Vincent Leung]]></dc:creator>
		<pubDate>Wed, 17 Dec 2014 22:00:00 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<guid isPermaLink="false">http://vincenthomedev.wordpress.com/?p=2126</guid>

					<description><![CDATA[Pick your Icon: http://fontawesome.io/icons/ Setup EASIEST: BootstrapCDN Add Font Awesome + Bootstrap into your website with two lines of code. You don&#8217;t even have to download or install anything! Paste the following code into the &#60;head&#62; section of your site&#8217;s HTML. &#60;link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css" rel="stylesheet"&#62; &#60;link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet"&#62; Want to use Font Awesome by itself without [&#8230;]]]></description>
										<content:encoded><![CDATA[<h4></h4>
<h4><a class="thickbox" href="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image1.png"><img loading="lazy" style="background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border:0;" title="image" src="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image_thumb1.png?w=240&#038;h=112" alt="image" width="240" height="112" border="0" /></a></h4>
<h3>Pick your Icon: <a href="http://fontawesome.io/icons/">http://fontawesome.io/icons/</a></h3>
<h1>Setup</h1>
<h4>EASIEST: <a href="http://www.bootstrapcdn.com/#tab_fontawesome">BootstrapCDN</a></h4>
<p>Add Font Awesome + Bootstrap into your website with two lines of code. You don&#8217;t even have to download or install anything!</p>
<ol>
<li>Paste the following code into the <code>&lt;head&gt;</code> section of your site&#8217;s HTML.
<pre><code>&lt;link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css" rel="stylesheet"&gt;
&lt;link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet"&gt;
</code></pre>
<p><i></i>Want to use Font Awesome by itself without Bootstrap? Just don&#8217;t include the first line.</li>
<li>Pat yourself on the back for your scalable-vector-icons-on-the-website <a href="http://37signals.com/svn/posts/312-lingo-judo">judo solution</a> in two lines of code.</li>
<li>Check out the <a href="http://fontawesome.io/examples/">examples</a> to start using Font Awesome!</li>
</ol>
<h4>EASY: Default CSS</h4>
<p>Use this method to get the default Font Awesome CSS with the default Bootstrap CSS.</p>
<ol>
<li>Copy the <code>font-awesome</code> directory into your project.</li>
<li>In the <code>&lt;head&gt;</code> of your html, reference the location to your font-awesome.min.css.
<pre><code>&lt;link rel="stylesheet" href="path/to/bootstrap/css/bootstrap.min.css"&gt;
&lt;link rel="stylesheet" href="path/to/font-awesome/css/font-awesome.min.css"&gt;
</code></pre>
</li>
<li>Check out the <a href="http://fontawesome.io/examples/">examples</a> to start using Font Awesome!</li>
</ol>
<h4>PRO: Custom LESS</h4>
<p>Use this method to customize Font Awesome and Bootstrap 2.3.2 using LESS.</p>
<ol>
<li>Copy the <code>font-awesome</code> directory into your project.</li>
<li>Open your project&#8217;s bootstrap/bootstrap.less and replace
<pre><code>@import "sprites.less";
</code></pre>
<p>with</p>
<pre><code>@import "path/to/font-awesome/less/font-awesome.less";
</code></pre>
</li>
<li>Open your project&#8217;s font-awesome/variables.less and edit the <code>@FontAwesomePath</code> variable to point to your font directory.
<pre><code>@FontAwesomePath:   "../font";
</code></pre>
<p><i></i>The font path is relative from your compiled CSS directory.</li>
<li>Re-compile your LESS if using a static compiler. Otherwise, you should be good to go.</li>
<li>Check out the <a href="http://fontawesome.io/examples/">examples</a> to start using Font Awesome!</li>
</ol>
<h1>Start using it</h1>
<p>After you get <a href="http://fontawesome.io/integration/">up and running</a>, you can place Font Awesome icons just about anywhere with the <code>&lt;i&gt;</code> tag:</p>
<pre><code>&lt;i class="icon-flag"&gt;&lt;/i&gt; icon-flag
</code></pre>
<p>You can also do <a href="http://fontawesome.io/examples/">http://fontawesome.io/examples/</a>:</p>
<ul>
<li>
<h4>Inline Icons</h4>
</li>
<li>
<h4>Larger Icons</h4>
</li>
<li>
<h4>Bordered &amp; Pulled Icons</h4>
</li>
<li>
<h4>Buttons <a class="thickbox" href="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image2.png"><img loading="lazy" style="background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border:0;" title="image" src="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image_thumb2.png?w=210&#038;h=50" alt="image" width="210" height="50" border="0" /></a></h4>
</li>
<li>
<h4>Button Groups <a class="thickbox" href="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image3.png"><img loading="lazy" style="background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border:0;" title="image" src="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image_thumb3.png?w=166&#038;h=38" alt="image" width="166" height="38" border="0" /></a></h4>
</li>
<li>
<h4>Button Dropdowns <a class="thickbox" href="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image4.png"><img loading="lazy" style="background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border:0;" title="image" src="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image_thumb4.png?w=103&#038;h=38" alt="image" width="103" height="38" border="0" /></a></h4>
</li>
<li>
<h4>Bulleted Lists <a class="thickbox" href="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image5.png"><img loading="lazy" style="background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border:0;" title="image" src="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image_thumb5.png?w=168&#038;h=87" alt="image" width="168" height="87" border="0" /></a></h4>
</li>
<li>
<h4>Navigation <a class="thickbox" href="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image6.png"><img loading="lazy" style="background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border:0;" title="image" src="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image_thumb6.png?w=240&#038;h=118" alt="image" width="240" height="118" border="0" /></a></h4>
</li>
<li>
<h4>Prepended &amp; Appended Form Inputs <a class="thickbox" href="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image7.png"><img loading="lazy" style="background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border:0;" title="image" src="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image_thumb7.png?w=211&#038;h=82" alt="image" width="211" height="82" border="0" /></a></h4>
</li>
<li>
<h4>Animated Spinner <a class="thickbox" href="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image8.png"><img loading="lazy" style="background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border:0;" title="image" src="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image_thumb8.png?w=43&#038;h=38" alt="image" width="43" height="38" border="0" /></a></h4>
</li>
<li>
<h4>Rotated &amp; Flipped <a class="thickbox" href="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image9.png"><img loading="lazy" style="background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border:0;" title="image" src="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image_thumb9.png?w=142&#038;h=127" alt="image" width="142" height="127" border="0" /></a></h4>
</li>
<li>
<h4>Stacked Icons <a class="thickbox" href="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image10.png"><img loading="lazy" style="background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border:0;" title="image" src="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image_thumb10.png?w=240&#038;h=94" alt="image" width="240" height="94" border="0" /></a></h4>
</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://vincenthomedev.wordpress.com/2014/12/17/font-awesome-get-started/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2126</post-id>
		<media:content url="https://1.gravatar.com/avatar/17028b12b45ce1b4a47f9306bd89aba97368840bf8fe4c0c6645a355498b9b20?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">Vincent Leung</media:title>
		</media:content>

		<media:content url="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image_thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image_thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image_thumb3.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image_thumb4.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image_thumb5.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image_thumb6.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image_thumb7.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image_thumb8.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image_thumb9.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="https://vincenthomedev.wordpress.com/wp-content/uploads/2013/07/image_thumb10.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>Self-Host ASP.NET WebAPI 2 using OWIN</title>
		<link>https://vincenthomedev.wordpress.com/2014/12/17/self-host-asp-net-webapi-2-using-owin/</link>
					<comments>https://vincenthomedev.wordpress.com/2014/12/17/self-host-asp-net-webapi-2-using-owin/#respond</comments>
		
		<dc:creator><![CDATA[Vincent Leung]]></dc:creator>
		<pubDate>Wed, 17 Dec 2014 17:31:28 +0000</pubDate>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[OWIN]]></category>
		<category><![CDATA[WebAPI]]></category>
		<guid isPermaLink="false">http://vincenthomedev.wordpress.com/?p=2387</guid>

					<description><![CDATA[Setup 1. Install-Package Microsoft.AspNet.WebApi.OwinSelfHost 2. Create a new class Startup.cs to configure the WebAPI public class Startup { &#160;&#160;&#160; public void Configuration(IAppBuilder appBuilder) &#160;&#160;&#160; { &#160;&#160;&#160;&#160;&#160;&#160;&#160; // Configure Web API for self-host. &#160;&#160;&#160;&#160;&#160;&#160;&#160; HttpConfiguration config = new HttpConfiguration(); &#160;&#160;&#160;&#160;&#160;&#160;&#160; config.Routes.MapHttpRoute( &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; name: &#8220;DefaultApi&#8221;, &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; routeTemplate: &#8220;api/{controller}/{id}&#8221;, &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; defaults: new { id = RouteParameter.Optional } &#160;&#160;&#160;&#160;&#160;&#160;&#160; [&#8230;]]]></description>
										<content:encoded><![CDATA[<h4> Setup</h4>
<p>1. Install-Package <strong>Microsoft.AspNet.WebApi.OwinSelfHost</strong></p>
<p>2. Create a new class <strong>Startup.cs</strong> to <strong>configure</strong> the WebAPI</p>
<blockquote>
<p><font size="2"><em>public <strong>class Startup</strong> <br />{ <br />&nbsp;&nbsp;&nbsp; public void Configuration(IAppBuilder appBuilder) <br />&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Configure Web API for self-host. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; HttpConfiguration config = new HttpConfiguration(); <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; config.Routes.MapHttpRoute( <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; name: &#8220;DefaultApi&#8221;, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; routeTemplate: &#8220;api/{controller}/{id}&#8221;, <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; defaults: new { id = RouteParameter.Optional } <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ); </em></font></p>
</blockquote>
<blockquote>
<p><font size="2"><em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; appBuilder.UseWebApi(config); <br />&nbsp;&nbsp;&nbsp; } <br />}</em></font> <br />&nbsp; </p>
</blockquote>
<p>3. Add a <strong>Controller derived from ApiController </strong>valuescontroller.cs</p>
<blockquote>
<p><font size="2"><em>public class ValuesController : <strong>ApiController</strong> <br />{ <br />&nbsp;&nbsp;&nbsp; // GET api/values <br />&nbsp;&nbsp;&nbsp; public IEnumerable&lt;string&gt; Get() <br />&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return new string[] { &#8220;value1&#8221;, &#8220;value2&#8221; }; <br />&nbsp;&nbsp;&nbsp; } </em></font></p>
</blockquote>
<blockquote>
<p><font size="2"><em>&nbsp;&nbsp;&nbsp; // GET api/values/5 <br />&nbsp;&nbsp;&nbsp; public string Get(int id) <br />&nbsp;&nbsp;&nbsp; { <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return &#8220;value&#8221;; <br />&nbsp;&nbsp;&nbsp; } </em></font></p>
</blockquote>
<blockquote>
<p><font size="2"><em>&nbsp;&nbsp;&nbsp; // POST api/values <br />&nbsp;&nbsp;&nbsp; public void Post([FromBody]string value) <br />&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp; } </em></font></p>
</blockquote>
<blockquote>
<p><font size="2"><em>&nbsp;&nbsp;&nbsp; // PUT api/values/5 <br />&nbsp;&nbsp;&nbsp; public void Put(int id, [FromBody]string value) <br />&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp; } </em></font></p>
</blockquote>
<blockquote>
<p><font size="2"><em>&nbsp;&nbsp;&nbsp; // DELETE api/values/5 <br />&nbsp;&nbsp;&nbsp; public void Delete(int id) <br />&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp; } <br />} </em></font></p>
</blockquote>
<p>&nbsp; </p>
<p>4. <strong>Start the Owin Host</strong> (Console App or a Windows Service)</p>
<p><font size="2"><em>static void Main() <br />{ <br />&nbsp;&nbsp;&nbsp; string baseAddress = &#8220;</em></font><a href="http://localhost:9000/&quot;;"><font size="2"><em>http://localhost:9000/&#8221;;</em></font></a><font size="2"><em>&nbsp;<br />&nbsp;&nbsp;&nbsp; <strong><font style="background-color:#ffff00;">Microsoft.Owin.Hosting.WebApp.Start&lt;Startup&gt;(url: baseAddress);<br /></font></strong>&nbsp;&nbsp;&nbsp; Console.ReadLine(); // Prevent Exit<br />}</em></font> </p>
<p>5. <strong>Calling the WebAPI<br /></strong></p>
<h6>Request</h6>
<p><font size="2"><em>GET </em></font><a href="http://localhost:9000/api/values"><font size="2"><em>http://localhost:9000/api/values</em></font></a><font size="2"><em> HTTP/1.1<br />Host: localhost:9000<br />Accept: application/json</em></font></p>
<h6>Response</h6>
<p><em><font size="2">HTTP/1.1 200 OK<br />Content-Length: 19<br />Content-Type: application/json; charset=utf-8<br />Server: Microsoft-HTTPAPI/2.0</font></em></p>
<p><em><font size="2">[&#8220;value1&#8243;,&#8221;value2&#8221;]</font></em></p>
<p>Reference: <a title="http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api" href="http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api">http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://vincenthomedev.wordpress.com/2014/12/17/self-host-asp-net-webapi-2-using-owin/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2387</post-id>
		<media:content url="https://1.gravatar.com/avatar/17028b12b45ce1b4a47f9306bd89aba97368840bf8fe4c0c6645a355498b9b20?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">Vincent Leung</media:title>
		</media:content>
	</item>
	</channel>
</rss>
