<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Asp.net 5 on Strathweb. A free flowing tech monologue.</title>
    <link>https://www.strathweb.com/categories/asp.net-5/</link>
    <description>Recent content in Asp.net 5 on Strathweb. A free flowing tech monologue.</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 28 Mar 2016 17:18:28 +0000</lastBuildDate><atom:link href="https://www.strathweb.com/categories/asp.net-5/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>The Subtle Perils of Controller Dependency Injection in ASP.NET Core MVC</title>
      <link>https://www.strathweb.com/2016/03/the-subtle-perils-of-controller-dependency-injection-in-asp-net-core-mvc/</link>
      <pubDate>Mon, 28 Mar 2016 17:18:28 +0000</pubDate>
      
      <guid>https://www.strathweb.com/2016/03/the-subtle-perils-of-controller-dependency-injection-in-asp-net-core-mvc/</guid>
      <description>&lt;p&gt;Some time ago I wrote a blog about &lt;a href=&#34;https://www.strathweb.com/2015/04/asp-net-mvc-6-discovers-controllers/&#34;&gt;how ASP.NET MVC 6 discovers controllers&lt;/a&gt;. While a lot has change since then, including the name - now the framework being called ASP.NET Core MVC, the post is still valid and the processes described there haven&amp;rsquo;t really changed.&lt;/p&gt;
&lt;p&gt;That said, there is one extra thing that should be added to it, and that is how external dependency injection containers relate to the process of controller discovery and instantiation, as there is a subtle difference between ASP.NET Core MVC and the &amp;ldquo;classic&amp;rdquo; frameworks - MVC 5 or Web API 2. This post is really sparked by the conversation on Twitter &lt;a href=&#34;https://twitter.com/jeremydmiller/status/712621955468275712&#34;&gt;with Jeremy and Kristian&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Re-using external view components in ASP.NET 5 &amp; ASP.NET MVC 6</title>
      <link>https://www.strathweb.com/2016/01/re-using-external-view-components-in-asp-net-5-asp-net-mvc-6/</link>
      <pubDate>Thu, 14 Jan 2016 22:37:12 +0000</pubDate>
      
      <guid>https://www.strathweb.com/2016/01/re-using-external-view-components-in-asp-net-5-asp-net-mvc-6/</guid>
      <description>&lt;p&gt;The other day we [explored using view components in ASP.NET 5][1] - as a very nifty replacement for the old MVC ChildActions. View components allow you to package a piece of functionality into a reusable class, along with an accompanying view, that can be invoke from any other view on demand.&lt;/p&gt;
&lt;p&gt;Today let’s take this a step further - and let’s see how you can configure ASP.NET MVC 6, to be able to consume view components not just from the current web project but from external sources - external assemblies too. This way you will be able to share and distribute your view components across multiple projects. This is definitely useful for anyone who has - for example - ever worked on a portal-style applications, where building reusable components is one of the most important development activities.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Running ASP.NET 5 website on IIS</title>
      <link>https://www.strathweb.com/2015/12/running-asp-net-5-website-on-iis/</link>
      <pubDate>Wed, 16 Dec 2015 19:04:46 +0000</pubDate>
      
      <guid>https://www.strathweb.com/2015/12/running-asp-net-5-website-on-iis/</guid>
      <description>&lt;p&gt;As &lt;a href=&#34;http://blogs.msdn.com/b/webdev/archive/2015/11/18/announcing-asp-net-5-release-candidate-1.aspx&#34;&gt;ASP.NET 5 hit RC1&lt;/a&gt; about a month go, more and more folks are looking at production deployments and other real life use cases of it. Going beyond demoware and experiments, to real applications, inevitably leads to thinking about hosting it somewhere - which, if your environment is Windows, most likely means IIS.&lt;/p&gt;
&lt;p&gt;I have recently gone through quite some trouble getting it all to work, so I thought it might be useful to document and highlight some of the steps, which hopefully will save a bit of your time.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Localized routes with ASP.NET 5 and MVC 6</title>
      <link>https://www.strathweb.com/2015/11/localized-routes-with-asp-net-5-and-mvc-6/</link>
      <pubDate>Fri, 13 Nov 2015 20:13:05 +0000</pubDate>
      
      <guid>https://www.strathweb.com/2015/11/localized-routes-with-asp-net-5-and-mvc-6/</guid>
      <description>&lt;p&gt;In my &lt;a href=&#34;http://www.apress.com/9781430259800&#34;&gt;Web API book&lt;/a&gt;, in one of the chapters (&lt;a href=&#34;https://github.com/filipw/apress-recipes-webapi/tree/2733cc683ecacc01d038d76756275201efdb63ec/Chapter%2003/3-11/Apress.Recipes.WebApi/Apress.Recipes.WebApi&#34;&gt;source here&lt;/a&gt;), I&amp;rsquo;m discussing an in interesting approach towards route localization, using attribute routing.&lt;/p&gt;
&lt;p&gt;The whole idea came from the fact that at some point in the past I used to work on a really large application - 70+ language versions, all of which required localizations on the route level.&lt;/p&gt;
&lt;p&gt;That approach allowed you to define a single attribute route at action level (as opposed to, well, 70+ routes), and have it auto-translated by the plugged in infrastructure, as long as you provide the mapping to other languages at application startup.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s have a look at how same type of functionality can be built in ASP.NET MVC 6.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Global route prefixes with attribute routing in ASP.NET 5 and MVC 6</title>
      <link>https://www.strathweb.com/2015/10/global-route-prefixes-with-attribute-routing-in-asp-net-5-and-mvc-6/</link>
      <pubDate>Fri, 16 Oct 2015 18:53:48 +0000</pubDate>
      
      <guid>https://www.strathweb.com/2015/10/global-route-prefixes-with-attribute-routing-in-asp-net-5-and-mvc-6/</guid>
      <description>&lt;p&gt;In the last post a few days ago we looked at &lt;a href=&#34;https://www.strathweb.com/2015/10/global-route-prefixes-with-attribute-routing-in-asp-net-web-api/&#34;&gt;adding a centralized route prefix&lt;/a&gt; to attribute routing in ASP.NET Web API.&lt;/p&gt;
&lt;p&gt;I got a couple of follow up question about how to achieve the same in ASP.NET 5 and MVC 6 framework. Let&amp;rsquo;s have a look then (btw: this article is written using beta8 version of ASP.NET 5).&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Running a C# REPL in a DNX application with scriptcs</title>
      <link>https://www.strathweb.com/2015/09/running-a-c-repl-in-a-dnx-application-with-scriptcs/</link>
      <pubDate>Tue, 15 Sep 2015 21:05:44 +0000</pubDate>
      
      <guid>https://www.strathweb.com/2015/09/running-a-c-repl-in-a-dnx-application-with-scriptcs/</guid>
      <description>&lt;p&gt;One of the cool things that &lt;a href=&#34;https://github.com/scriptcs/scriptcs&#34;&gt;scriptcs&lt;/a&gt; allows you to do, is that you can embed it into your application and allow execution of C# scripts. There are even some great resources on that out there, like &lt;a href=&#34;http://madstt.dk/endeavours-with-scriptcs-hosting/&#34;&gt;this awesome post by Mads&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The same applies to the REPL functionality - you don&amp;rsquo;t have to use &lt;em&gt;scriptcs.exe&lt;/em&gt; to access the REPL - you can use the scriptcs Nuget packages to create a REPL inside your app.&lt;/p&gt;
&lt;p&gt;And because there aren&amp;rsquo;t that many resources (if any) on how to host a scriptcs REPL, today I wanted to show you just that. But for a more interesting twist, we&amp;rsquo;ll do that inside a DNX application.&lt;/p&gt;
&lt;p&gt;There are many reasons why DNX is awesome, and why you&amp;rsquo;d want to use it, but especially because, through the &lt;em&gt;project.json&lt;/em&gt; project system, it has a much improved way of referencing and loading dependencies and Nuget packages - and we can leverage that mechanism to feed assemblies into our REPL.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>ViewComponents in ASP.NET 5 and ASP.NET MVC 6</title>
      <link>https://www.strathweb.com/2015/07/viewcomponents-asp-net-5-asp-net-mvc-6/</link>
      <pubDate>Wed, 15 Jul 2015 11:28:00 +0000</pubDate>
      
      <guid>https://www.strathweb.com/2015/07/viewcomponents-asp-net-5-asp-net-mvc-6/</guid>
      <description>&lt;p&gt;Let&amp;rsquo;s have a quick look at another new feature in ASP.NET MVC 6, and that is the &lt;em&gt;ViewComponent&lt;/em&gt; feature. View components are intended to be replacements to &lt;em&gt;ChildActions&lt;/em&gt; and, to some extent, of partial views.&lt;/p&gt;
&lt;p&gt;Traditionally in ASP.NET MVC (and in general in the textbook MVC pattern), you had to compose the entire model in the controller and pass it along to the view, which simply rendered the entire page based on the data from the model. The consequence of this is that the view does not need to explicitly ask for any data - as its sole purpose is to just act upon the model it received.&lt;/p&gt;
&lt;p&gt;While this sounds very nice in theory, it has traditionally posed a number of practical difficulties. There are a number of reusable components on pretty much every website - think a menu, a shopping cart, lists of all kinds, breadcrumbs, metadata and so on - so things that appear on multiple pages.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s have a look at how this is solved in MVC 6.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Migrating from Web API 2 to MVC 6 at NDC Oslo</title>
      <link>https://www.strathweb.com/2015/07/migrating-web-api-2-mvc-6-ndc-oslo/</link>
      <pubDate>Thu, 09 Jul 2015 10:06:04 +0000</pubDate>
      
      <guid>https://www.strathweb.com/2015/07/migrating-web-api-2-mvc-6-ndc-oslo/</guid>
      <description>Last month I gave a talk about migrating from Web API to MVC 6 and ASP.NET 5 at NDC Oslo.
Below you can find the the video, code and slides from the session.
Thanks for all who attended, I had a great time in Oslo! Hopefully we get to revisit this session soon too, when ASP.NET 5 becomes a bit more mature.
Video 🔗You can watch the talk on Vimeo.</description>
    </item>
    
    <item>
      <title>Action filters, service filters and type filters in ASP.NET 5 and MVC 6</title>
      <link>https://www.strathweb.com/2015/06/action-filters-service-filters-type-filters-asp-net-5-mvc-6/</link>
      <pubDate>Mon, 08 Jun 2015 21:29:12 +0000</pubDate>
      
      <guid>https://www.strathweb.com/2015/06/action-filters-service-filters-type-filters-asp-net-5-mvc-6/</guid>
      <description>&lt;p&gt;Today, let&amp;rsquo;s have a look at he area of filters in ASP.NET MVC 6 - because it actually contains quite a few interesting changes compared to classic MVC and Web API filter pipelines.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s leave the specialized filters (error filters, authorization filters) on a side for now, and focus instead on the functional, aspect oriented, filters. Aside from the good old action filters, known from both MVC and from Web API, there are two new types of filters (or rather filter factories, but we&amp;rsquo;ll get there) that you can use - &lt;em&gt;ServiceFilters&lt;/em&gt; and &lt;em&gt;TypeFilters&lt;/em&gt;.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Integration testing ASP.NET 5 and ASP.NET MVC 6 applications</title>
      <link>https://www.strathweb.com/2015/05/integration-testing-asp-net-5-asp-net-mvc-6-applications/</link>
      <pubDate>Tue, 19 May 2015 11:05:06 +0000</pubDate>
      
      <guid>https://www.strathweb.com/2015/05/integration-testing-asp-net-5-asp-net-mvc-6-applications/</guid>
      <description>&lt;p&gt;The other day I ran into a &lt;a href=&#34;https://alexanderzeitler.com/articles/Integration-testing-ASP.NET-5-Controllers-with-DNX-Beta4/&#34;&gt;post by Alex Zeitler&lt;/a&gt;, who blogged about integration testing of ASP.NET MVC 6 controllers. Alex has done some great work for the Web API community in the past and I always enjoy his posts.&lt;/p&gt;
&lt;p&gt;In this case, Alex suggested using self hosting for that, so spinning up a server and hitting it over HTTP and then shutting down, as part of each test case. Some people have done that in the past with Web API too, but is not an approach I agree with when doing integration testing. If you follow this blog you might have seen my post about testing &lt;a href=&#34;https://www.strathweb.com/2013/12/owin-memory-integration-testing/&#34;&gt;OWIN apps&lt;/a&gt; and &lt;a href=&#34;https://www.strathweb.com/2012/06/asp-net-web-api-integration-testing-with-in-memory-hosting/&#34;&gt;Web API apps&lt;/a&gt; in memory already.&lt;/p&gt;
&lt;p&gt;My main issue with the self-host approach, is that you and up testing the underlying operating system networking stack, the so-called &amp;ldquo;wire&amp;rdquo; which is not necessarily something you want to test - given that it will be different anyway in production (especially if you intend to run on IIS). On the other hand, you want to be able to run end-to-end tests quickly anywhere - developer&amp;rsquo;s machine, integration server or any other place that it might be necessary, and doing it entirely in memory is a great approach.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>ASP.NET MVC 6 formatters – XML and browser requests</title>
      <link>https://www.strathweb.com/2015/04/asp-net-mvc-6-formatters-xml-browser-requests/</link>
      <pubDate>Fri, 24 Apr 2015 11:32:15 +0000</pubDate>
      
      <guid>https://www.strathweb.com/2015/04/asp-net-mvc-6-formatters-xml-browser-requests/</guid>
      <description>&lt;p&gt;A while ago I &lt;a href=&#34;https://www.strathweb.com/2014/11/formatters-asp-net-mvc-6/&#34;&gt;wrote a post&lt;/a&gt; about formatters in MVC 6.&lt;/p&gt;
&lt;p&gt;Since then, there have been some changes regarding XML handling and an interesting feature that was added recently that was not part of that post, so I think it warranties a follow up. XML formatter is now removed by default. On top of that, MVC 6 will attempt to sniff out whether your request is originating from a browser&amp;rsquo;s address bar and adjust content negotiation accordingly.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>How ASP.NET MVC 6 discovers controllers?</title>
      <link>https://www.strathweb.com/2015/04/asp-net-mvc-6-discovers-controllers/</link>
      <pubDate>Wed, 01 Apr 2015 09:58:29 +0000</pubDate>
      
      <guid>https://www.strathweb.com/2015/04/asp-net-mvc-6-discovers-controllers/</guid>
      <description>&lt;p&gt;In the past I did a couple of blog posts (&lt;a href=&#34;https://www.strathweb.com/2013/08/customizing-controller-discovery-in-asp-net-web-api/&#34;&gt;here&lt;/a&gt; and &lt;a href=&#34;https://www.strathweb.com/2012/06/using-controllers-from-an-external-assembly-in-asp-net-web-api/&#34;&gt;here&lt;/a&gt;) about how ASP.NET Web API discovers controllers.&lt;/p&gt;
&lt;p&gt;ASP.NET MVC 6 supports both regular controllers (inheriting from &lt;em&gt;Controller&lt;/em&gt; base type) and POCO controllers. Let&amp;rsquo;s have a look at how the discovery of them happens in ASP.NET MVC 6. Note that the code and mechanisms discussed in this article were introduced after ASP.NET 5 beta3 was released, so it is not yet available if you use the version of ASP.NET 5 bundled with Visual Studio 2015 CTP6.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Strongly typed routing for ASP.NET MVC 6 with IApplicationModelConvention</title>
      <link>https://www.strathweb.com/2015/03/strongly-typed-routing-asp-net-mvc-6-iapplicationmodelconvention/</link>
      <pubDate>Wed, 11 Mar 2015 18:28:27 +0000</pubDate>
      
      <guid>https://www.strathweb.com/2015/03/strongly-typed-routing-asp-net-mvc-6-iapplicationmodelconvention/</guid>
      <description>&lt;p&gt;This is something I hacked together last night, but it was a very interesting exercise into customizing the new (or rather, future) ASP.NET MVC 6 to suit your needs.&lt;/p&gt;
&lt;p&gt;If you visit this blog from time to time, some time ago I &lt;a href=&#34;https://www.strathweb.com/2014/07/building-strongly-typed-route-provider-asp-net-web-api/&#34;&gt;blogged about building strongly typed routing provider for ASP.NET Web API&lt;/a&gt; (&lt;a href=&#34;https://github.com/filipw/Strathweb.TypedRouting&#34;&gt;code is here&lt;/a&gt;). That was built around extensibility points provided by the direct routing mechanism (better known as direct routing&amp;rsquo;s default implementation - attribute routing).&lt;/p&gt;
&lt;p&gt;So I thought, it would be fun to port this solution to MVC 6. However, while MVC 6 supports attribute routing, it does not provide the same abstractions over the routing mechanism. Instead it exposes something new for both MVC and Web API developers - &lt;em&gt;IApplicationModelConvention&lt;/em&gt;, which is what we&amp;rsquo;ll use here.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Overriding filters in ASP.NET MVC 6</title>
      <link>https://www.strathweb.com/2015/02/overriding-filters-asp-net-mvc-6/</link>
      <pubDate>Thu, 12 Feb 2015 11:05:48 +0000</pubDate>
      
      <guid>https://www.strathweb.com/2015/02/overriding-filters-asp-net-mvc-6/</guid>
      <description>&lt;p&gt;There are many posts out there, including on this blog, about &lt;em&gt;what&amp;rsquo;s in&lt;/em&gt; ASP.NET MVC 6 and how to use it. This one however, will be about &lt;em&gt;what&amp;rsquo;s not in&lt;/em&gt; the framework, or at least not in the same way as you might be used to it from MVC 5/Web API 2 - the ability to override filters. I was recently working on an MVC 6 project and ran into this exact problem.&lt;/p&gt;
&lt;p&gt;In MVC 5 and Web API 2, there was a &lt;a href=&#34;https://www.strathweb.com/2013/06/overriding-filters-in-asp-net-web-api-vnext/&#34;&gt;built in way to do it&lt;/a&gt;, and even though it was not very extensible, it proved to be very handy (at least for me).&lt;/p&gt;
&lt;p&gt;IN MVC 6, these override filters are gone, so at first glance, filter overriding is quite difficult. In reality, that&amp;rsquo;s not the case, you just need to know what to do - let&amp;rsquo;s have a look.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Migrating from ASP.NET Web API to MVC 6 – exploring Web API Compatibility Shim</title>
      <link>https://www.strathweb.com/2015/01/migrating-asp-net-web-api-mvc-6-exploring-web-api-compatibility-shim/</link>
      <pubDate>Wed, 21 Jan 2015 12:59:52 +0000</pubDate>
      
      <guid>https://www.strathweb.com/2015/01/migrating-asp-net-web-api-mvc-6-exploring-web-api-compatibility-shim/</guid>
      <description>&lt;p&gt;Migrating an MVC 5 project to ASP.NET 5 and MVC 6 is a big challenge given that both of the latter are complete rewrites of their predecessors. As a result, even if on the surface things seem similar (we have controllers, filters, actions etc), as you go deeper under the hood you realize that most, if not all, of your pipeline customizations will be incompatible with the new framework.&lt;/p&gt;
&lt;p&gt;This pain is even more amplified if you try to migrate Web API 2 project to MVC 6 - because Web API had a bunch of its own unique concepts and specialized classes, all of which only complicate the migration attempts.&lt;/p&gt;
&lt;p&gt;ASP.NET team provides an extra convention set on top of MVC 6, called &lt;a href=&#34;https://github.com/aspnet/Mvc/tree/dev/src/Microsoft.AspNet.Mvc.WebApiCompatShim&#34;&gt;&amp;ldquo;Web API Compatibility Shim&amp;rdquo;&lt;/a&gt;, which can be enabled make the process of migration from Web API 2 a bit easier. Let&amp;rsquo;s explore what&amp;rsquo;s in there.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>ASP.NET MVC 6 attribute routing – the [controller] and [action] tokens</title>
      <link>https://www.strathweb.com/2015/01/asp-net-mvc-6-attribute-routing-controller-action-tokens/</link>
      <pubDate>Wed, 07 Jan 2015 12:28:29 +0000</pubDate>
      
      <guid>https://www.strathweb.com/2015/01/asp-net-mvc-6-attribute-routing-controller-action-tokens/</guid>
      <description>&lt;p&gt;When working with attribute routing in Web API 2 or MVC 5 it was relatively easy to get the route to the controller and the controller name out of sync. That was because the route always had to be specified as a string, so whenever you changed the name of the controller you would always have to change the string in the route attribute too.&lt;/p&gt;
&lt;p&gt;That could be easily forgotten - especially if you use refactoring tools of Visual Studio or an external refactoring plugin.&lt;/p&gt;
&lt;p&gt;This issue has been addressed in MVC6 with a tiny addition - the introduction of &lt;em&gt;[controller]&lt;/em&gt; ad &lt;em&gt;[action]&lt;/em&gt; tokens into attribute routing.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Razor views pre-compilation with ASP.NET 5 and MVC 6</title>
      <link>https://www.strathweb.com/2014/12/razor-views-pre-compilation-asp-net-5-mvc-6/</link>
      <pubDate>Fri, 12 Dec 2014 10:36:22 +0000</pubDate>
      
      <guid>https://www.strathweb.com/2014/12/razor-views-pre-compilation-asp-net-5-mvc-6/</guid>
      <description>&lt;p&gt;In previous versions of MVC framework, running on top of the &amp;ldquo;classic&amp;rdquo; ASP.NET runtime, it was quite common for developers to switch view compilation on, so that the views get compiled upfront, allowing you to see any errors at compile time, rather than at runtime.&lt;/p&gt;
&lt;p&gt;This was done by a simply adding &lt;em&gt;&lt;MvcBuildViews&gt;true&lt;/MvcBuildViews&gt;&lt;/em&gt; to your &lt;em&gt;csproj&lt;/em&gt; file.&lt;/p&gt;
&lt;p&gt;Given that everything changes in the new ASP.NET 5 world, how would you do it now? Let&amp;rsquo;s explore.&lt;/p&gt;</description>
    </item>
    
  </channel>
</rss>
