Skip to content →

Category: ASP.net

SEAI and Microsoft Azure Case Study

Microsoft have put together a nice little case study with SEAI on a project that we recently built. It was a full PaaS solution built on Azure websites, using a Cloud style architecture incorporating queues and webjobs for processing carbon credits and managing load on the site.

Leave a Comment

ASP.NET vNext – Packing and Publishin

These are my notes from the ASP.NET vNext Community Standup

Packing and Publishing

Packing and Publishing is the process of taking the source and static files as they are represented in my source tree and staging them into a folder structure ready to xcopy onto a server.

The underlying process uses the KPM command line tool, which has a number of switches for options to control the output.

There are levels out publishing:

  1. Move the files and folders and pull in the nuget packages ready for deployment
  2. Same as above, but compile all the *.cs files into a dll

The KRE runtime can now run code without it having to be compiled first.  This enables deployment to be a simple xcopy of the source files. If you want to compile all the source files up front then rather than compiling them to a traditional bin folder they will get compiled into a nuget package and get deployed into the packages folder. This is an important point as it means that all executable C# code is modular and managed at the package level.

You starting folder structure will look similar to the below tree structure, this is the structure that would get checked-in to your source control provider.

  • $/
    • src
      • MyWebApp
        • project.json
        • files.cs
        • wwwroot
          • static files

All external nuget packages would be references under the dependencies node of your project.json file, however your packages are pulled down from the remote repository and stored in a local cache in your user profile. When your application runs the KRE runtime will probe for the packages and use the cached versions.

Packing the solution using kpm and the pack command will generate an xcopyable deployable.

kpm pack –out output file path

Output directory structure

  • output file path
    •  wwwroot
      • web.config
      • static files
    • approot
      • packages
        • nuget packages
      • src
        • project.json
        • x.cs

This separation of source code and static files means that code can never be served.

IIS or Kestrel anchors to the wwwroot folder.

If your decided to compile your application when you package the output folder structure would look similar to the below:

  • output file path
    •  wwwroot
      • web.config
      • static files
    • approot
      • packages
        • nuget packages
        • MyAppPackage

The MyAppPackage represents your source code compiled to a nuget package, the package process all pulls all cached versions of the dependent nuget packages so that they can be xcopy deployed.

Using wild cards in version numbers enables automatic updates to dependencies without having to reupdate

KRE – is the new runtime, this can be included in the packages folder if the CLR is not already installed on the target machine.

CLR can be either remote deployed onto a server and shared, or deployed locally within the packages folder which will take precedence.

F5 != kpm pack

The Visual Studio publish UI uses this underlying command.

 

 

Leave a Comment

ASP.NET vNext – Entity Framework 7 Design (Notes)

My notes from the ASP.NET Community Standup 4

Main goal of ASP.NET is to shink down the memory footprint of a Request.

Data access is a first class tenant of web applications, therefore Entity Framework is becoming a first class tenant of ASP.NET.

EF is becoming portable and is trying to provide a single consistent programming model for all data access, on the server, on the desktop, tablet of mobile.

EF 7, is also a complete rewrite. To make EF lighter the underlying EDMX has been removed, making it more modular and light weight.  Little code is being moved forward, the focus is more on the API, designs and conventions that people have adopted.

EF 7 will be a PCL Nuget package, with the objective that it can run on Mono, Xamarin etc.

Providers will include Redis, Azure Table Storage.

No Model First, no designer. Only Code first using annotations and fluent api, however it will still include reverse engineering to generate code from an existing database table.

EF7 is not recommended for a complex datamodel, its focus is on providing a common abstraction over simple datamodels.

Indexes will now become a first class citizen of the mapping infrastructure so that they can be managed via code first. Providers can use this metadata to generate their own interpretation of an index based on their store.

Providers are created for each type of data store. There are some helpers for providers creating Linq. There is some capabilities for projecting those Linq expressions in memory when the underlying data store does not support Linq.

EF7

Shipping Providers

  • MS SQL Server
  • SQL Lite
  • Azure Table Storage
  • Redis Provider

Heavy focus on performance and memory management, including batching, change tracking and the output sql generation.

If you want the EDMX and designer you should use EF6 which will be fully supported for the foreseeable future.

Leave a Comment

ASP.NET vNext – Razor, Directives and Tag Helpers (Notes)

These are my notes from the ASP.NET vNext Community Standardup 3

 

Razor Views now support async processing out of the box.

This is particularly important for ASP.NET webpages or using Razor outside the normal MVC lifecycle.

Razor now supports incremental flushing, so that HTML can be streamed to the browser. This is enabled using a new “@await FlushAsync()” razor command that can be called within the page.

 

Dependency injection is now plumbed into Razor.

@inject

@inject IFoo Foo

Components can now be injected via IoC into a View

 

The default helpers have been removed from the base class and are now injected using the Injection mechanism. This means that you can expand your own Helpers

 

Use _ViewStart pages

Now _ViewStart supports directives, so that we can use the @inject directive to set global properties, _ViewStart files can be cascaded and nested.

Pre compilation is still around and will be turned on by default.

 

Available directives

@inject IFoo Foo

@using My.Comapny.Namespace

@inherits points to the base class

@model use this model across the lifes

 

Templating

Model C# class

Validation based on Attributes on Model

Razor template to generate AngularJS Template, and then client side AngularJS processes template

 

Tag Helpers

Provides a solution to support better HTML manipulation similar to how AngularJS manipulate HTML

Example

<input for=”FirstName” class=”form-field” />

<tag-cloud count=”2″ />

This extension improves the authoring of Razor files and provides better intellisence.

This does not enable a server side dom, you can access the view string, but you would have to manipulate this yourself, however this is not recommended as it limits the buffering and thus speed of the page.

Intent of feature is not to become server side DOM but to improve HTML helpers with HTML style syntax.

 

 

Leave a Comment

ASP.NET vNext – Webroot, static content and client side serving (Notes)

Notes from the ASP.NET vNext community stand up.

Web Root, Static Content and client side serving

A new project sub-folder that is the route folder that your webserver hosts e.g. IISExpress would point to the WebRoot folder no instead of the Project Route. Within this folder you will place all the static content that would get served by the webserver. The purpose of this folder is to provide better security and better support for a front end build process. Therefore this folder is where the output of any frontend build process using Gulp, Grunt or Bower would go. It can be thought of as the bin folder for static files and WebRoot can be viewed as

If you have moved to using bower to manage your front end assets, then you would have a task runner to copy your assets from bower_components to the WebRoot.

WebRoot would not be checkedin to your source control folder, as its built as part of the build process.

This is a very common pattern for Ruby & NodeJS developers.

Build orchestration on Windows within Visual Studio will use new project file type, appname.kproj which is an MSBuild file for Visual Studio, however MSBuild is not used for compilation as compilation is done at run time.

 

Publishing processes within Visual Studio to compile and build a package for publishing use the KPack solution.

Recommendations

  • Build out a front end build process using Grunt, Gulp and Bower.
  • Move minified/transformed content files from bower_components to a separate content folder

Reference

https://www.youtube.com/watch?v=fNJ70gRmPWU&list=PL0M0zPgJ3HSftTAAHttA3JQU4vOjXFquF&index=6

Leave a Comment

ASP.NET vNext, How & why? (Notes)

 

What is ASP.NET vNext?

  • New flexible and cross-platform runtime
    • Run it on Windows
    • Run it on Mac
      • Using Mono
    • Run it on Linux
      • Using Mono
  • Modular HTTP request pipeline
    • No more System.Web
    • Baremetal performance
    • Supports OWIN
  • Built cloud ready
    • Fully self contained, not coupled to .NET framework
    • Slimmed down to a CoreCLR
    • Use only the components of the baseclass library that you need using Nuget
    • Side by side deploy
    • No GAC or binding policies
  • Friendly frameworks
    • All references pulled in using Nuget at runtime
  • Agile development with the tools of your choice
    • Visual Studio 14
      • New project system that removes the “build” set between code & F5
    • Command line – Full Command line support
    • 3rd party editors – Sublime support
  • Open source on GitHub

In an effort to create an experience as close to Ruby & NodeJS ASP.NET vNext will do build compilation at run time unless you choose to do pre compilation.

Inversion of Control

You apps will be fully componentised and provisioned from the ground up using the inbuilt “inversion of control” (IoC) container.  Providers are not configured in Web.config any more but are replaced with a IoC, you can rip out the provided one and use your own.

Take away: If you are already using an IoC (Castle Windsor, Autofac) you will be in a good position here, however the recommendation is to start using one.

Bower & Grunt

Although many people have been publishing front-end frameworks using Nuget e.g. AngularJS, JQuery etc, Nuget is not great at managing the content files. Rather than extend Nuget the team have taken the decision to implement first class support for Bower & Grunt.

Take Away: This functionality has already been packaged into a number of Visual Studio extensions so that you can start adopting this work flow with Visual Studio 2013, alternatively you can use the Bower Nuget package.

Using Environment Variables for identifying configuration

Rather than compile and package for application for each environment and run the associated web.config transforms, ASP.NET will now use a preconfigured Environment Variable to determine which environment it is running in and make associated configuration changes. We can already do this today by creating our own Environment variables and querying them at run time.

No web.config – replaced with your own providers e.g. Json file, environment variables and IoC for provider configuration

Deep integration with Roslyn & Nuget

Real-time compilation and debugging enables whole new code-debug-run scenarios, especially when it comes to 3rd party references. Examples of cloning via git, referencing and compiling where given in talks that represents a much fast and open developer cycle than the more common use of published, compiled binaries.

Take away: keep on track with understanding Roslyn, no need to go into deep understanding but keep playing with it.

Harmonised frameworks

Web Pages, MVC & WebAPI have all been harmonised together

MVC + WebAPI + Web Pages = ASP.NET MVC 6

Both Web Pages will now be built on the same basics as MVC & WebAPI. Web Pages will have a clear upgrade model to MVC.

Moving forward – Compatibility

Web Forms, MVC 5, Web API 2, Web Pagaes 3, SignalR 2, EF 6

Fully supported on .NET vNext (NOT ASP.NET vNext)

MVC, Web API, Web Pages 6, SignalR 3

Run on new runtime and request pipeline only (no System.Web.dll)

To migrate MVC app, you will have to create a new project and migrate!!!!

Cloud Optimised RunTime

Very slimmed down version of CoreCLR, could take a while!!!

API portability scanner to find out if your code will port

 

RTW Release Q2 2015

References

Leave a Comment

Principles for building a Successful Continuous Integration System

Below is a list of the core principles that have defined the  CI solutions that I have built over the last few years.

Use the lowest common denominator in technology for scripting

This has meant that the main workflows have been written in PowerShell rather than MSBuild or Nant as its more accessible, a terser language, can use .Net framework directly & debuggable.

I have seen too many systems that need loads of dependencies installed before you can run a build e.g. Using Ruby as a build language

Everything should be in source control

As a developer I want to install VS & SQL, get latest, build and go.

That means no “installed” dependencies, they all need to be mapped into the source tree or pulled in from Nuget

No build masters

The build should be something that everybody understands, can fix and improve

Team leads should be the custodians of a project build as they are the people that should have  the big picture view of a project

You broke it you fix it

Exactly what it says on the box. It does not matter if its a code, unit test or build script failure. If you changed something that means the build has stopped working then you fix it.

Same build for local as remote

A lot of build systems hold the configuration on the server, I believe this to be wrong.

I want to be able to run the same build that’s on the server on my local machine before I commit
Everything the build server does should be available for me to me locally.

Dashboards & emails are great but a flashing light is better

The last system I built had a flashing tractor light and a USB Santa drumming Christmas tunes when the build was broken, makes things a little more fun!!!

The below books really shaped my attitude to CI and contain invaluable information.

http://pragprog.com/book/auto/pragmatic-project-automation

http://www.amazon.com/Continuous-Delivery-Deployment-Automation-Addison-Wesley/dp/0321601912

Leave a Comment

Free SEO Tools

Over the last few years I have had to complete a number of SEO reviews of websites. Rather than focus on keywords and rankings, I focus on the technical implementation of HTML, content and URLs to make sure that they are inline with the Google SEO Start Guide. I firmly believe that there is no point spending money on SEO consultants when the website does not adhere to the basics.

Following the developer mantra of automate everything I wrote a number of scripts to help me process these pages.

Today I have finally found some time to bundle them up into a simple website and deployed them to the cloud for everybody to use.

If you like them or have ideas about how they could be improved please let me know.

Glyn Darkin’s Free SEO tools

Leave a Comment

BDD, Cucumber, .Net & Specflow

Specflow

On the first day of my first proper software development role in London I  was handed the amazing book Pragmatic Unit Testing in C# with NUnit by my software development manager and told to read it. It is a great book but I always struggled to apply the principles into my daily workflow. I absolutely believe in everything that TDD tries to achieve, however I have never managed to find the right balance of Unit Tests/Integration Tests.

I have work with some awesome developers who have all struggled to apply TDD into their everyday workflow (So it’s not just me!!).

The majority of projects I have worked on have been very data focused and often I have had to work with crappy frameworks that were difficult to unit test. MS Commerce Server being one of them.

I have always been interested in what the Ruby On Rails community do and I have been following their BDD experiments for some time.

The Rails guys dont seem to be afraid of their databases and have incorporated it directly into their stack. They seem to be less worried about mocking out dependencies,  or running against test data, they just get on a build, creating tests as they go.

So I started looking more closely at Cucumber, a BDD framework used commonly in the Rails community.

Straight away I could see a way of organising tests and building a regression pack that would start adding value to our team, and then I found SpecFlow.

Its genius

The Specflow guys have taken the DSL used in Cucumber and added a code generator so that you can use it with a testing framework. We have it set up with NUnit and already within a couple of days we are flying with it.

Cucumber

Finally things seem comfortable. The language makes sense to everybody, testers, BAs and devs alike. The output of the tests is slowly moulding itself into the way we make and describe our code, and it is driving some really interesting discussion about when is something done. Plus it is helping us in planning, as very quickly user stories are getting blown out with more requirements than would have normally been addressed in the first round of planning.

Getting started with Specflow is easier than you could imagine.  This screen cast is 30mins long, but it covers everything you need to know to get up and running.

Enjoy and happy testing.

Leave a Comment

I love Redgate!!!!

I have just spent the day debugging the ASP.Net Membership provider as I had an issue where users could not log into the my test server.

Redgate have added a new addin to the ever excellent Reflector, that enables you to debug third party assemblies from within Visual Studio. How amazing is that!!

I was able to debug through the membership provider and find out where things were going wrong.

As it goes the error was due to my own stupidity, aren’t they all, but it saved me hours.

Another Red Gate tool  that has become  a permanent part of my development tool kit.

I have to mention that SQL Compare is also excellent.

Leave a Comment