Showing posts from September, 2009

Twitter And The Courtesy Of Retweeting

Twitter’s strong word-of-mouth characteristics are derived from the common courtesy of retweets of its user base, not on technology – this is changing with an announcement this week. This arbitrary courtesy is the flaw that could lead to its demise once Twitter becomes more commonplace and the tight knit group of early adopters finds that courtesy gets undermined. For example: I have 100 followers and I post an event notification for the small city I live in. One of my followers (call him @WhatcomTravel) decides that this posting is relevant to his/her followers and decides to retweet my posting. By common courteous he starts the post RT: @myusername which gives me credit for the original posting. If he has 2000 followers, some of them will start to follow me to if they feel my postings are relevant to their interest. In essence they go to the source. Here lies the issue; if they follow me it dilutes the attention that they pay to the person that retweeted my post (@WhatcomTrav

Not That Obvious In MVC

I am working on converting some ASP.NET WebForms pages into MVC Views and there are a couple of things I have run across in MasterPages that are not obvious in the beginning. With ASP.NET WebForms if you wanted dynamic content in your MasterPage one way to do it is to have the code behind of the MasterPage insert it, which means that your Page either need to tell the Master Page what to insert or the Master Page need to figure it out. Take this for example: < head > < meta name ="Description" content ="" id ="metaDescription" runat ="server" /> </ head > Here I am trying to add a meta description the head of the HTML so that the search engines know what this page is about. What I was doing is have the page check the type of the master class on the pages OnInit event and if it was the right master class, find the public property in the MasterPage that would set the MetaDescription. When the MasterPage pre-rende

Upgrading WebForms .csproj to MVC

So you followed all the steps to upgrade your old ASP.NET WebForms project to ASP.NET MVC: added the necessary entries to the web.config, created a Views and Controllers directory, and added the necessary references. However, when you right click to add a new item to the Controllers directory (or Views directory) in Visual Studio 2008 there are no MVC items available. You need to update the .csproj view a text editor to "tell" it that it is a MVC project. Here is how: 1. Close out of Visual Studio. 2. Open .csproj file of the web site in notepad 3. In the beginning of file there is PropertyGroup block. Find the ProjectTypeGuids tag. 4. Add {603c0e0b-db56-11dc-be95-000d561079b0} as first project type GUID, the delimiter is a semi-colon. 5. Save the file . Now you can open the solution again in Visual Studio 2008 and you will have the MVC items. {6230289B-5BEE-409e-932A-2F01FA407A92}

Update To RegExRoute Class

Update with a few new constructors that allow you to use the MvcRouteHandler, and some bug fixes. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web.Routing; using System.Web.Mvc; using System.Text.RegularExpressions; namespace WebUtility { public class RegexRoute : RouteBase { public Regex Regex { get; private set; } public String[] Groups { get; private set; } private IRouteHandler RouteHandler { get; set; } public String Controller { get; private set; } public String Action { get; private set; } /// <summary> /// Creates A Regular Expression Route /// </summary> /// <param name="regex">Regular Expression To Use Against /// the AbsolutePath of the request.</param> /// <param name="groups">roups In The Match</param> /// <param name="routeHa

Application_Start Only Once

Quick note about Application_Start that I noticed when working with ASP.NET MVC. It gets called only once. Which makes total sense, since the application only starts once. However, it gets run only once even if there is an exception thrown from the code within Application_Start. Which means if RegisterRoutes throws an exception, then you need to trigger the application to reset, otherwise your routes will not be registered on the next call. For Example: 1) You code a new route in RegisterRoutes. 2) Compile 3) You request a page, this calls Application_Start 4) There is an exception in your route and RegisterRoutes throws an exception. 5) You attach the debugger. 6) You request the page again to reproduce the error. This is where you notice that the error doesn't happen again, since Application_Start has already been called and attaching the debugger doesn't restart the application. Here are some of the things I know that restarts the application: 1) Edit the web.config

RegularExpression Routing Class for MVC

I am working with a ASP.NET WebForms website trying to convert it over to ASP.NET MVC 1.0 and need to make sure all the old URLs route correctly. We were using a combination of an HTTPHandler and Custom 404 redirects to give the web site some fancy URLs -- now I need to mimic that functionality with MVC in order not to lose the Google links that the site depends on for revenue. We really only care about the name part of the URI and the hint that it ends in .htm (the .htm extension is mapped to the ASP.NET ISAPI extension handler). So the route I tried to add looked like this: routes.Add( new Route( "{*path}/{name}.htm" , new NameRouteHandler())); However, I got this error message: A catch-all parameter can only appear as the last segment of the route URL. Which was an issue; the path which I tossed away had a lot of optional subdirectories which didn't map well to the MVC Route syntax. What I really wanted was to treat