Categories
Programming

Translating Your ASP.NET MVC Routes

There are a ton of ways to localize your ASP.NET MVC application when it comes to the text your display on the page. When it comes to the URLs, though, it is not uncommon to see a site in one language with routes in another. It seems a real shame to see a website in […]

Categories
Programming

Request and Response Class Splitting

This is something I don’t seen done a lot in real life, so I thought I’d write briefly about it. This topic gets a lot of talk, but not much action and in reality I think schedule pressures are the most likely reason for this refactoring (and most others) never actually get considered. I’m talking […]

Categories
Programming

Testing Your MVC Routes

Everyone knows that is much easier to test a controller in MVC than it was to test “code behind” in Web Forms, but it is really easy to forget that routing rules are a rather important chunk of your logic. If the routing isn’t right, everything else fails. So you ought to be testing your […]

Categories
Programming

Adding Unity to Your Web API Project

Adding Unity V3 to your ASP.NET Web API project is so easy it very nearly hurts. Despite this, I can foresee a couple of “duh” moments if you don’t spot a couple of minor details. To get started, you just open up the NuGet package manager, search online for Unity and select the appropriate version […]

Categories
Programming

Why You Never Expose your Domain Model as your MVC Model

Having helped a lot of programmers to take their first steps with ASP.NET MVC, I can safely say that the most common rookie error is to re-use your domain model in your view model. I can see why people do it – it seems like the right thing to do when you have DRY beaten […]

Categories
Programming

The Name BundleConfig Does Not Exist in the Current Context

Given that there are currently no results on The Web that give a good answer to the following error, I thought I’d help out and supply the information. The error is… “The name ‘BundleConfig’ does not exist in the current context” Usually this means you have the following line of code in your Global.asax.cs file, […]

Categories
Programming

Using CORS with ASP NET Web API

If you are writing an ASP.NET Web API and you want to call it from a JavaScript (CoffeeScript, TypeScript) program on another domain, here are the steps you need to take to make it happen. I know that you are smart and you know what you are doing, so I’m not bulking out this article […]

Categories
Programming

Get Your MVC Models Right

It seems like every time someone shows off their ASP.NET MVC application to me I have to make the same observation about their models, so I’ve decided to put the explanation online to save myself a great deal of repetition. As we all know, the Model in ASP.NET MVC is how information travels from the […]

Categories
Programming

ASP NET MVC Post/Redirect/Get Pattern

This is just a quick article to hopefully dispel some common misunderstandings of the ASP.NET MVC Post/Redirect/Get Pattern. First up, a quick explanation of what the Post/Redirect/Get (or PRG) Pattern is for those who don’t know. The Problem With A POST The common problem is that if you submit a form, you end up on […]

Categories
Programming

JavaScript Includes and Rewritten URLs

I recently answered a question on a forum about JavaScript includes in ASP.NET MVC and as the question came up again today, I thought I’d share the answer with the world. The issue that people are coming up against is that they have a script include with a relative path to their script file. Because […]