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).
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!
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.
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
publicclassMyCorsPolicy : 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.
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.
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:
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.
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.
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!
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.
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.
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.
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.
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:
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.
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.
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.
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.