Archive

Posts Tagged ‘MVC’

Setting up a CDN

Quick one to show how we handle DevOPS here at Simple Innovations.

The challenge is to set up a Content Delivery Network (CDN) in Azure so that all of the images on our new web site can be served as close to the end user as possible.

The classic DevOPS method would be to start from script and get it just right but in this case we only need to do it once so why not use the Azure portal to do it?

Read more…

Categories: Deployment Tags: , , , ,

Enum support in ASP.NET MVC

Hi Folks

So what happened to enum support in ASP.NET?

It was working and then, it stopped.

Well enum support is in MVC 5.1 and by default the Visual Studio templates are still using MVC 5.0 for generating new projects.

The solution is simple enough.

  1. Upgrade MVC in the project.
  2. Find all references to enum types and replace EditorFor with EnumDropDownListFor.

E.g. replace

@Html.EditorFor(model => model.Colour)

with

@Html.EnumDropDownListFor(model => model.Colour)

So how do we get our solutions to use 5.1 by default, and going forward 5.2, 6.0, etc?

Good question and one that doesn’t seem to have that easy an answer as if you chase down the project template, held in “C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\ProjectTemplates\CSharp\Web\1033\WebTemplate45”, you’ll find.

    <WizardExtension>
<Assembly>Microsoft.VisualStudio.Web.Project, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
<FullClassName>Microsoft.VisualStudio.Web.Project.OneASPNetProjectTemplateWizard</FullClassName>
</WizardExtension>

So its code that does it not configuration.

Thus the best thing seems to be a ‘checklist’ for new projects.

  1. Create Project.
    1. Explicitly select ASP.NET 4.5.1
  2. Update NuGet Packages
    1. MVC ASP.NET 5.1.2

Cheers

Sebastian