Tag Archive: ASP.NET MVC


Bundle virtual-paths should not be duplicated, otherwise the dupe will overwrite the contents of the previous entry. To add more than one file to a bundle, wrap them in the params in the Include method.

For example, in BundleConfig.cs RegisterBundles, this:

bundles.Add(new StyleBundle("~/bundles/css").Include("~/Content/xxx.less"));
bundles.Add(new StyleBundle("~/bundles/css").Include("~/Content/yyy.less"));

Needs to be this:

bundles.Add(new StyleBundle("~/bundles/css").Include(

Also, the bundle virtual path depth should be the same as the depth of the file you are referring to (4 in the example below). If you don’t do this, relative paths in your less/css will fail.

	bundles.Add(new LessBundle("~/Content/xxx/less/yyy").Include("~/Content/xxx/less/yyy.less"));

Universal Caching

I wrote this library so I don’t have to keep track if I should use HttpRuntime.Cache, AppDomain.CurrentDomain.SetData, HttpContext.Current.Session, or a Dictionary…now I just use GlobalCache or UserCache.  It also makes unit testing a webapp a snap, because if you use IGlobalCache/IUserCache in your code, you just inject the Windows-based cache in your unit test setup.

You can download the solution with dlls here: Universal Caching solution

Upgrading ASP.NET MVC and controller factory says “no suitable method found to override”

If you upgrade from MVC 1 to 2 or higher and your controller factory (such as StructureMapControllerFactory) throws a “no suitable method found to override” error for your GetControllerInstance method, be sure you have a reference to System.Web.Routing:

using System.Web.Routing;

And be sure you add the RequestContext parameter to the GetControllerInstance method call like this:

protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)

How to eliminate magic strings from Html.DropDownListFor

Magic strings are just nuclear-powered bug magnets. They attract fat-fingering mistakes while coding and practically guarantee bugs will be introduced while refactoring. If you’re like me, you’ll hate the magic strings required in the Html.DropDownListFor as much as I do. Now there’s an easy way to get rid of them once and for all…

View full article »

How to POST model if GET action has parameter in ASP.NET MVC

Do you have a post action that accepts a parameter (and what post action doesn’t?), but you also have a get action that accepts a parameter and you are seeing that submits are going back to the get action and other strange behavior? Here’s how you fix that:

View full article »

© 2017 Robert Corvus