Currently Browsing: ASP.NET MVC

ASP.NET MVC Spark Support

ASP.NET MVC 2 supports Spark! What? hear me out. The release of ASP.NET MVC 2 includes an amazing hidden gem. You see the “Add View/Controller” dialog now takes into account a T4 directive “output extension”. Getting started with Custom CodeTemplates To get started with Custom CodeTemplates check out this excellent article by K. Scott Allen Getting started with Custom CodeTemplates and Spark At the top of your templates add the output extension as shown below. Modify the template to use spark.
read more
Page 1 of 3123

Spark View Engine 1.1

ASP.NET MVC 2 was RTM’ed today and with the help of Jay Harris – @jayharris we upgraded our rather large codebase to not only ASP.NET MVC 2 RTM but also a new drop of the Spark View Engine built against the RTM. Since the release of Spark View Engine 1.1 RC a few weeks ago there have been some minor bugs/enhancements identified but no blockers. The update to RTM was nothing more then changing the assembly reference, build number and running the build script. These changes are not yet reflected in on the GitHub source. I’m sure there will be a pull request or Lou – @loudej will...
read more
Page 1 of 3123

Spark Binaries For ASP.NET MVC RC2

THIS IS NOT AN OFFICAL RELEASE…YET I spent the evening updating the spark source to support ASP.NET MVC RC/RC2. Well, actually I simply applied the changes that were posted to either the mailing list or codeplex. All the tests pass: Download it here: Binaries: Spark-1.0.1.0-release.zip Source: Spark-1.0.1.0-source.zip This post, hopefully, won’t be up long.
read more
Page 1 of 3123

ASP.NET MVC2 To Provide Real Spark Support

Ok, that might be going a little too far but it sounds like the barrier I wrote about a few weeks ago might be going away. Earlier this evening Phil Haack posted this tweet: Excited to hear this I asked a leading implementation question about honoring the output extension directive in T4 templates. Us old-timer remember the almost year before ASP.NET MVC 1.0, when we had not tooling support inside visual studio. Right before 1.0 was released we got right-click view/controller support and it made a world of difference. I honestly believe that without the GUI integration, that pushed us to use...
read more
Page 1 of 3123

SOA+MVC

Disclaimer: This post is my personal reflection of a current situation. It’s not intended for any other use. Don’t use this information in anyway. Background The previous enterprise-grade SOA architected systems I’ve worked on, last decade, were Classic ASP, Java or Webforms. These systems had their presentation layer wired directly into the services. The largest, .NET or other, MVC application I worked with was huge MVC but it had a “traditional” connection to the database.   First thoughts on SOA+MVC
read more
Page 1 of 3123

ASP.NET MVC: Not That Open Source

ASP.NET MVC has one small hook into Visual Studio, the ability to right click and add views and controllers. This feature is small, hell since I’ve been using spark I almost forgot about it, that is until I started working on a simple administration section. The application has enough entities that “Right Click –> Crud” would make just the right tool. Idea ASP.NET MVC provides customizable code templates for the view/controller content. There are a few really good articles on how to get started. Plan Include the CodeTemplates in my project Change the output extention to .spark...
read more
Page 1 of 3123

Validating DataAnnotations

public static IList<String> GetClassLevelErrors(object instance){ return TypeDescriptor.GetAttributes(instance).OfType<ValidationAttribute>() .Where(attribute => !attribute.IsValid(instance)) .Select(attribute => attribute.FormatErrorMessage(string.Empty)) .ToList();} [TestMethod]public void TestMethod1(){ var prop = typeof (DataAnnotationsModelBinderSpike.Models.Contact).GetProperty("First"); var attrib = prop.GetCustomAttributes(true).Cast<RequiredAttribute>().FirstOrDefault(); Assert.IsNotNull(attrib);}
read more
Page 1 of 3123

Base Controller Class and TempData

Need: To pass information to every view based on an environmental variable. The specific case I ran across this need is when you want to use the minified version of your JavaScript libraries in production and the human readable in dev/QA. Solution: Create your own base controller class. Override either onactionexecuting or onactionexecuted. Populate TempData with the environment specific information. Change your controllers to inherit from your custom base controller Use that information in the view. using System.Configuration;using System.Web.Mvc; namespace BaseController.Controllers{...
read more
Page 1 of 3123

ASP.NET MVC Routing domain.com/*

Scenario; you have to pass wildcard requests to a controller for processing. Think myspace.com style vanity names. Solution: Not as nice as .htaccess but it works; and I think I’m doing it write. Step 1: Add Routes to Global.asa 1: routes.MapRoute( 2: "Default", 3: "{controller}/{action}/{id}", 4: new { controller = "Home", action = "Index", id = "" }, 5: new { controller = new Constraints("Account", "User", "Home") } 6: ); 7:   8: routes.MapRoute( 9: ...
read more
Page 1 of 3123

Tools I want to use more

As a follow up to my tools post here is a list of the tools I’d like to spend more time with. The % next to the title is an estimation as the likelihood I’ll do any serious work with the tool/software/etc. ReSharper – 20% http://www.jetbrains.com/resharper/ Simply put, ReSharper is a must-have productivity tool for .NET developers. It fully integrates with Visual Studio to intelligently and powerfully extend the functionality that is native to Visual Studio. ReSharper provides solution-wide error highlighting on the fly, instant solutions for found errors, over 30 advanced code refactorings,...
read more
Page 1 of 3123