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:

image

Excited to hear this I asked a leading implementation question about honoring the output extension directive in T4 templates.

image

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 strong-typed views, MVC would have taken longer to get into less progressive shops.

I’m really excited about MVC2 …but it still needs a logo.

image

image

Related posts:

  1. Spark with VB.NET Project Demo #2
  2. ASP.NET MVC New Project Replace Webforms with Spark

read more

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.

Backgroundimage

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

No related posts.

read more

AutoMapper.Silverlight

I could, and will soon, write a long ass post about how I cobbled together a messed-up architecture for building Silverlight applications on top of an enterprise class SOA architecture without RIA but with RIA…

Here is a branch of AutoMapper, compiled against Silverlight and now with support for entities generated from WCF service references.

http://github.com/detroitpro/AutoMapper.Silverlight

I really hope I published it to GitHub correctly; yell at me if not.

Related posts:

  1. Thoughts on Silverlight
  2. Silverlight, Actions and Prism
  3. ESRI Silverlight Map vs. Prism Regions

read more

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.

image

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.

image

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

  1. Include the CodeTemplates in my project
  2. Change the output extention to .spark
    1. image
  3. Modify the markup to sparkup
  4. Phase 3: Profit.

Problem

ASP.NET MVC uses a custom tool to process the T4 templates.

MvcTextTemplateHost

It ignores the output extension directive in T4 templates.

(Click play)

The Price is Right Losing Horns sound bite

Sadness

MvcTextTemplateHost is included in Microsoft.VisualStudio.Web.Extensions.dll and this DLL that is not “part” of MVC code that was open sourced.

Conclusion

I’d love to write a Visual Studio addin to create spark views but I just don’t have the time. However; I do wonder if I can just have spark parse the .aspx and .ascx files.

No related posts.

read more

ASP.NET MVC in Action Personal Notes

  1. Keep using a custom controller
  2. Learn and Use Ajax Helpers More
  3. Rob Conery’s Law: When you have an “if” statement in the view, make a helper!
    1. I think this might be optional depending on your view engine. Spark almost solves? this problem.
  4. I miss dynamic languages.
  5. Please with model binding as a way to create a terse application/framework.

No related posts.

read more

TFS and Blend

Changes you make in Blend will NOT show up in your pending changes in TFS. hence, they will not be pushed to the server and as such you will lose all your work when you do a “get latest and overwrite existing” since TFS FUCKING SUCKS!

No related posts.

read more

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);}

No related posts.

read more

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{    public class BaseController : Controller    {        protected override void OnActionExecuting(ActionExecutingContext filterContext)        {

            filterContext.Controller.TempData["OnActionExecuting"] = "OnActionExecuting";            filterContext.Controller.TempData["js_dev"] = ConfigurationManager.AppSettings["js_dev"];

            base.OnActionExecuting(filterContext);        }

        protected override void OnActionExecuted(ActionExecutedContext filterContext)        {

            filterContext.Controller.TempData["OnActionExecuted"] = "OnActionExecuted";            filterContext.Controller.TempData["js_prod"] = ConfigurationManager.AppSettings["js_prod"];            base.OnActionExecuted(filterContext);        }    }}

Pros:

  • I’ve found that I often have to create my own base controller class. Doing so for something this simple is a god starting point.

Cons:

Alternate Solutions:

  • Use T4 templates to generate a const file based on environment.
  • Put the information of each server in the machine.config

Final:

The solution is sound and a sample is attached but I am going to have to come back and flesh out this post a little more with details about the *.config/caching and other options.

No related posts.

read more

Help! Looking for a CSS DSL!

Update: Today Less CSS for .NET, or just .Less,  was released. Its a port of the ruby LESS library and exactly what I was/am looking for. I updated my question on SO already.

—– old post ——

I posted this on stackoverflow.com already…..

I’ve been working on a really large project for almost 2 years and the client requirements keep changing. These changes, of course, effect everything and I would like to find a way to work with the CSS in a more dynamic fashion.

I assume I could get one of the ruby or python CSS DSLs running under ironRuby/Python but this client is very very particular about what software/frameworks are installed.

I have not found a CSS DSL where the base programming language is vb or c#.

reference: http://sandbox.pocoo.org/clevercss/ and http://nubyonrails.com/articles/dynamic-css

I guess another question is has anyone got either of these frameworks working under IronPython or IronRuby?

No related posts.

read more

Unrecognized attribute ‘targetFramework’

Change the app pool to target the .NET 4.0 Framework…it defaults to 2.

No related posts.

read more
Page 1 of 1112345»...Last »