Community Update 2014-02-21 – #OWIN, #ASPNET and of course #Azure Mobile Services

First we have a nice post on MSDN about integrating claims with OWIN. I’ve read the article and it’s definitely easier.

Then we have the integration of the OWIN pipeline with the new .NET Azure Mobile Services as well as a test drive of the WS-Federation in the new Katana 3.0.0-alpha1 (available on NuGet with the -Pre flag).

Finally, serving WebP images with ASP.NET MVC.

Enjoy the weekend!

OWIN

Using Claims in your Web App is Easier with the new OWIN Security Components (blogs.msdn.com)

Running the OWIN pipeline in the new .NET Azure Mobile Services (www.strathweb.com)

Test driving the WS-Federation Authentication Middleware for Katana | leastprivilege.com on WordPress.com (leastprivilege.com)

ASP.NET

Serving WebP images with ASP.NET MVC – Randoom (friism.com)

Katana 3.0.0 alpha1 released

The package was released yesterday under the name Microsoft.Owin and the version 3.0.0-alpha1 on NuGet.

The release is actually planned for April as per the roadmap. What is planned in this released?

  • WS-Federation - Middleware component supporting the WS-Federation protocol for federated identity in an OWIN pipeline.
  • Remove support for .NET Framework 4.0 in order to exclusively use async await

But from the changesets, it appears to be that the first point one delivered.

So what is WS-Federation? It’s a standard for securing web services that has been made by Oracle, Microsoft and way more companies.

For more information, I recommend this MSDN Library article for a more thorough understanding.

If you try it, keep me posted on Twitter @MaximRouiller.

Community Update 2014-02-20 – #aspnet, #azure, a sample app and #elasticsearch bonuses

So first of all, we have new releases coming from Azure, if you’re not registered yet… subscribe to The Gu’s blog and never miss it again!

Then we have a SqlDependency/SqlCacheDependcy with EF for ASP.NET Caching and one nice sample SPA application with Angular and WebAPI.

As always, a bonus on ElasticSearch including on how to deploy ElasticSearch on Azure.

Enjoy!

ASP.NET

Azure

Application/Sample

ElasticSearch

Community Update 2014-02-19 – #owin discussions, lots of #aspnet links including #serilog and more

So there is a ton of posts today. It’s like everyone was working on getting Wednesday full of content! Luckily for you, you don’t have to crawl through the Twitter firehose. I did it for you.

So here is what need to grasp your attention today!

Enjoy!

OWIN discussions

ASP.NET

Videos

Code

Dynamic #CORS Origin based on Request domain with #WebAPI

So here is the situation, I’m currently working on a website that has multiple environment but all share the same base domain.

As an example let’s say we have those:

  • staging.mydomain.com
  • qa.mydomain.com
  • dev.mydomain.com

Since I don’t want to share my domains with everyone by adding the CORS allowed origins directly from those, I want to my this dynamic for *.mydomain.com but without the wildcard.

First, you’ll need the Microsoft.AspNet.WebAPI.Cors package on NuGet.

You’ll need to add the following in your WebApiConfig.cs:

1
2
3
4
public static void Register(HttpConfiguration config)
{

config.EnableCors();
}

However, that method allow us to set a custom policy. Like so:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class MyCorsPolicy : ICorsPolicyProvider
{
public Task<CorsPolicy> GetCorsPolicyAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{

var policy = new CorsPolicy();

var requestUri = request.RequestUri;
var authority = requestUri.Authority.ToLowerInvariant();
if (authority.EndsWith(".mydomain.com") || authority == "mydomain.com")
{
// returns a url with scheme, host and port(if different than 80/443) without any path or querystring
var origin = requestUri.GetComponents(System.UriComponents.SchemeAndServer, System.UriFormat.SafeUnescaped);
policy.Origins.Add(origin);
}

return Task.FromResult(policy);
}
}

So with that default policy, we allow anyone from a subdomain to make request to us without having to store a list of every subdomain that could contact us.

Of course, you could also set allowed methods, headers and such in this policy.

Enjoy!

Community Update 2014-02-18 – #ASPNET, #Owin with Helios, #CQRS with no databases

So just a few links today.

First we have a nice Web Developer checklist that I think everyone should see. Then Levi Broderick write us a niec intro to what is Project Helios. If you are the least bit concerned with ASP.NET, it should be on your top articles to read today. No exceptions.

Finally, we have a nice article from Gabriel Schenker about not using a database when using an article similar to CQRS.

And as always, a little bonus on an ElasticSearch 101.

Enjoy!

ASP.NET

CQRS

ElasticSearch

How to parse an RSS and ATOM feed from pure .NET without plugins

Let’s throw an hypothetic scenario… you want to know when one of your favorite blogger post something. Maybe that blogger post his updates to Twitter and you can follow that. But sometimes they don’t. Or maybe you are building a system to aggregate their content.

Then you start looking for plugins on how to do it properly and you don’t find much.

Let me show you how to do it without plugins.

Prerequisite

  • .NET 3.5 SP1

 

Step 1 : Retrieve the data

First let’s make our code compatible with multiple feeds. We’ll collect a list of URLs from a few very popular blogs.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
var rssFeeds = new List<Uri>
{
new Uri("http://weblogs.asp.net/scottgu/rss.aspx"),
new Uri("http://feeds.hanselman.com/ScottHanselman"),
new Uri("http://blogs.msdn.com/b/dotnet/rss.aspx"),

};
var client = new HttpClient();

foreach (var rssFeed in rssFeeds)
{
var result = client.GetStreamAsync(rssFeed).Result;

// todo: implement the rest
}

Step 2: Parse the data to retrieve the proper value

Okay, now we have the RAW XML from any RSS or Atom feed. We’ll need to parse that data somehow. Let me introduce you to the SyndicationFeed.

1
2
3
4
5
6
7
8
9
using (var xmlReader = XmlReader.Create(result))
{
SyndicationFeed feed = SyndicationFeed.Load(xmlReader);

if (feed != null)
{
// todo: loop over feed.Items?
}
}

The SyndicationFeed is a built-in RSS and Atom parser found in the .NET Framework. No need for plugins here.

In my scenario however, I needed the Author name. With those 3 feed, you will find none of them if you are inspecting the code. Here’s what is fun however. The format is extensible.

Let’s retrieve an extension value.

Step 3: Retrieve Extension Values like “dc:creator” or “dc:publisher”

So those extensions are described in the Dublin Core. As an example, you can see creator and publisher. Those are used in pretty much all Blog Engines like WordPress and BlogEngine.NET.

You will find those extension on each different blog post which is represented in C# by the SyndicationItem (in the array feed.Items from earlier). Here are the extensions method I built to retrieve them:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public static class SyndicationItemExtensions
{
public static string GetCreator(this SyndicationItem item)
{

var creator = item.GetElementExtensionValueByOuterName("creator");
return creator;
}

public static string GetPublisher(this SyndicationItem item)
{

var publisher = item.GetElementExtensionValueByOuterName("publisher");
return publisher;
}

private static string GetElementExtensionValueByOuterName(this SyndicationItem item, string outerName)
{

if (item.ElementExtensions.All(x => x.OuterName != outerName)) return null;
return item.ElementExtensions.Single(x => x.OuterName == outerName).GetObject<XElement>().Value;
}
}

Now we should be able to retrieve the author quite easily.

Step 4: Access the values

So let’s rewrite Step 2 but with us trying to find the author of an RSS feed.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
using (var xmlReader = XmlReader.Create(result))
{
SyndicationFeed feed = SyndicationFeed.Load(xmlReader);

if (feed != null)
{
var item = feed.Items.First();

string creator = item.GetCreator();
string publisher = item.GetPublisher();

var blogAuthor = (feed.Authors.FirstOrDefault() ?? new SyndicationPerson()).Name;
var chosenAuthor = creator ?? publisher ?? blogAuthor;
Console.WriteLine(" Chosen author: {0}", chosenAuthor);
}
}

Here is the output from Console

1
Chosen author: ScottGu
Chosen author: Scott Hanselman
Chosen author: The .NET Fundamentals Team

Conclusion

So without any extensions, I was able to parse RSS feeds. If you have a blog, you should try it on your own and see how that works. On my end, my blog was misconfigured by showing “My Name” as one of those entries.

So if you need more info, don’t hesitate to reach me on Twitter @MaximRouiller.

Enjoy!

Community Update 2014-02-17 – #aspnet, #webapi, #owin and some #angularjs

I’m bringing you some old stuff with the Page Life Cycle but it’s a necessary read. If you haven’t read it yet and you are still working with WebForms, I suggest you take a look.

Rick Strahl brings us 2 very interesting post. One for enabling WebAPI Basic Authentication and one for a bug that slipped in recent KB update. So if your WebForms default to MVC login URL, check that out.

On the OWIN side of things, a new release of Security providers brings you a whole lot of new supported OpenID provider and half-ogre brings you a basic pattern to lambda dispatcher for OWIN.

Enjoy!

ASP.NET

OWIN

JavaScript

Community Update 2014-02-14 – Valentine’s day, let’s show some love for #EventSourcing and #ElasticSearch

So not much time for blogging for this Valentine’s day community update. However, there is a nice article from InfoQ about high availability and Event Sourcing. Definitely a must read/watch.

And we’ll close the lover’s day by 2 articles on scaling ElasticSearch. You might have already seen the first one but in cased you missed it, it’s there!

Enjoy!

Event Sourcing

Scaling ElasticSearch Series

Community Update 2014-02-13 – #aspnet #identity, some more #rest ranting and one podcast

So let’s keep things simple. ASP.NET Identity in blog posts and in podcasts. And to cover it all, some more REST ranting.

I like a day that goes focused and simply.

Enjoy!

ASP.NET

REST

Podcasts

Community Update 2014-02-12 – Small day with only #aspnet and #elasticsearch

So not a lot of articles were worth mentioning today. So I’ll leave you with only this. A follow-up article by Brock Allen, an integration of ADFS with ASP.NET and VS2013.

Do not miss the release of ElasticSearch 1.0. It was released just a few hours ago and is still hot.

Enjoy!

ASP.NET

Introducing IdentityReboot | brockallen on WordPress.com (brockallen.com)

Use the On-Premises Organizational Authentication Option (ADFS) With ASP.NET in Visual Studio 2013 | CloudIdentity (www.cloudidentity.com)

ElasticSearch

Elasticsearch.org This Week In Elasticsearch | Blog | Elasticsearch (www.elasticsearch.org)
Elasticsearch.org 1.0.0 Released | Blog | Elasticsearch (www.elasticsearch.org)

Community Update 2014-02-11 – #signalr and #owin running on #mono and #RaspberryPi, more #rest versioning

Okay, my first link is a video of a project that runs a Self-Hosted OWIN server on a Raspberri PI with Mono. How awesome is that? Open-source awesome that is! Okay… it says that it’s slow but still… who dreamt of running that on this type of devices?

That part done, you will find some more link on extending System.Web.Optimization as well as the new Identity framework.

Make sure to take a look at the many discussions listed on how REST API versioning is done in the wild.

Bonus: ElasticSeach as usual.

Enjoy

OWIN

ASP.NET

REST

ElasticSearch

Community Update 2014-02-10 – #rest API versioning, building a file server with #owin, #helios and ElasticSearch with #D3js

It looks like today is the day of ASP.NET, OWIN and REST API versioning.

Among those, I would recommend checking out the video by Damian Edwards (one of the guy that works on SignalR) about what NOT to do. If you don’t have the time, at least read the article by Scott Hanselman.

As an additional bonus, a simple post about data visualization with nothing else than ElasticSearch and D3.

Enjoy!

Owin & Katana

REST and API Versioning

ASP.NET

ElasticSearch

Community Update 2014-02-07 – Creating custom filters with #ASPNET #MVC and viewing a GitHub repo with #ElasticSearch and #Kibana

First, a few filters with ASP.NET. Rendering your content as PDF with Jimmy Bogard’s (you should subscribe to his blog!) as well as a Visual Studio Magazine article that’s worth reading.

As for ElasticSearch, we have a nice article on its distributed nature as well as how to establish a “river” on ElasticSearch.

So on this very slow news Friday, I’ll wish you all a nice weekend.

ASP.NET

ElasticSearch

#Kibana in #IIS – Error loading dashboards with JSON extension

So I’ve found this small problem and it’s been referenced before. So as I was installing Kibana in my local IIS 8, it had problem loading files due to an error in MIME type for files with a JSON extension.

If you find that you are having the same problem, just put the following Web.config file at the root:

1
2
3
4
5
6
7
8
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
</configuration>

Community Update 2014-02-06 – #aspnet to #windows8 transition, building modern web apps and a French #CQRS article

So this is the update from yesterday. I left a little bit too fast and totally forgot to press Publish. So there will be another post today.

A series of video has been released by Microsoft with Scott Hanselman and Scott Hunter to show you how to build modern web apps with ASP.NET. You don’t want to miss that so I linked to Scott Hanselman’s announcement as well as the series on Channel 9. Included in this, we have a Visual Studio Magazine article on transitioning from ASP.NET to Windows 8 development.

And a rare article in French on CQRS for those that are interested.

Enjoy!

ASP.NET & Web API

Best Practices for Transitioning from ASP.NET to Windows 8 Development – Visual Studio Magazine (visualstudiomagazine.com)

Building Modern Web Apps with ASP.NET - A new day of free ASP.NET Training for 2014 - Scott Hanselman (www.hanselman.com)

Building Modern Web Apps (channel9.msdn.com) – The actual video for the previous introduction by Scott Hanselman

Host ASP.NET Web API in an Azure Worker Role : The Official Microsoft ASP.NET Site (www.asp.net)

Dynamic action return with Web API 2.1 - StrathWeb (www.strathweb.com)

Tools

Recaptcha for .NET - Home (recaptchanet.codeplex.com)

CQRS - Français

Greg Young, sur l’utilisation du Complex Event Processing (www.infoq.com)

ElasticSearch

Introduction to Elasticsearch, Logstash and Kibana // Speaker Deck (speakerdeck.com)

Community Update 2014-02-05 – #dotnet poster, #saaskit for #owin, #webapi and #rest with Scott Hanselman

Let’s start this post by saying that we have a poster of the .NET universe in 2013. Downloadable directly from Microsoft. Very fun to look at and hang on the ceiling of your living room after being moved to the couch by your significant other for trying to do the same thing in the bedroom.

Then we have the usual Scott Hanselman post about some WebAPI and how to go around server host that do not allow PUT/DELETE verbs.

Finally, since I’m a big fan of ElasticSearch, I’m including their changelog for what’s new in the newest release.

Enjoy!

.NET

ASP.NET & OWIN

ElasticSearch

Community Update 2014-02-04 – #ElasticSearch, #Architecture and some #OWIN and #aspnetmvc love

We do have some very great content today. Do not miss out on the architecture section since they are very interesting. We also have some deep-dive on OWIN host and a detailed explanation of the ASP.NET MVC execution pipeline.

If you are trying out ElasticSearch and thinking about putting it in production, do check the pre-flight checklist to ensure that you optimize/secure your instance as much as possible.

As a bonus, a video about WolfSpider a graph tool that groups your contacts together and separate them. Lots of not-.NET tech in there but the video is worth it.

Enjoy!

Architecture

ASP.NET & OWIN

Video

ElasticSearch

Community Update 2014-01-31 – #owin authentication in #aspnetmvc, #cqrs with #rest and #Azure plugin with #ElasticSearch

Not necessarily a lot of content today but a few stuff that is super interesting. First, John Galloway brings us in the future of ASP.NET for 2014. A must read of course.

Do not miss the free book by Stanford University about Information Retrieval. If you are using ElasticSearch with Azure VMs, you will want this plugin that will allow you to scale any ElasticSearch cluster directly in the cloud without any big problems.

Enjoy the weekend!

OWIN & ASP.NET

CQRS

Free books

Azure & ElasticSearch

Community Update 2014-01-30 – Performance test #wcf versus #webapi, Tips for #aspnet and #azure webjobs

ASP.NET & WebAPI

5 Tips to Improve Your ASP.NET MVC Codebase - Tech.Pro (tech.pro)

Revisting Projecting and the OData $expand Query Option | Beyond The Duck (beyondtheduck.com)

REST WCF vs. WebAPI (throughput performance) (blogs.msdn.com)

ASP.NET MVC under the hood part 6 (www.pieterg.com)

Azure

Getting Started with the Windows Azure WebJobs SDK : The Official Microsoft ASP.NET Site (www.asp.net)

Miscellaneous

Technology Radar January 2014 | ThoughtWorks (www.thoughtworks.com)

Announcing preview of Dynamic Data provider and EntityDataSource control for Entity Framework 6 (blogs.msdn.com)