<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Not Rocket Science &#187; asp.net mvc</title>
	<atom:link href="http://www.stum.de/category/development/aspnet-mvc-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.stum.de</link>
	<description>Random thoughts of neat disorder</description>
	<lastBuildDate>Sun, 08 Aug 2010 00:16:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>A slight Nitpick/Improvement for Tekpubs Video about ASP.net MVC Routing</title>
		<link>http://www.stum.de/2010/03/28/a-slight-nitpickimprovement-for-tekpubs-video-about-asp-net-mvc-routing/</link>
		<comments>http://www.stum.de/2010/03/28/a-slight-nitpickimprovement-for-tekpubs-video-about-asp-net-mvc-routing/#comments</comments>
		<pubDate>Sun, 28 Mar 2010 10:49:47 +0000</pubDate>
		<dc:creator>mstum</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[asp.net mvc]]></category>

		<guid isPermaLink="false">http://www.stum.de/?p=779</guid>
		<description><![CDATA[Tekpubs series about ASP.net MVC 2 is really useful and has tons and tons of great tips and code samples, and the episode about Routing (#12) is no exception. However, there is one thing I really didn't like about it. Around 30 Minutes in when discussing SEO Optimizations, they show a great tip how to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://tekpub.com/preview/aspmvc">Tekpubs series</a> about ASP.net MVC 2 is really useful and has tons and tons of great tips and code samples, and the episode about Routing (#12) is no exception. However, there is one thing I really didn't like about it.</p>
<p>Around 30 Minutes in when discussing SEO Optimizations, they show a great tip how to enforce canonical URLs. Unfortunately, they do it by modifying the Response object directly. Basically the code looks like</p>
<pre class="prettyprint lang-cs">
// This snippet doesn't make much sense if you haven't
// watched the Episode, sorry.
public ViewResult Details(int id)
{
    //snipped some parts
    EnforceCanonicalUrl(jobAd.DetailsRouteValues());
    return View(jobAd);
}

private void EnforceCanonicalUrl(RouteValueDictionary routeValues)
{
    if(someCheckFails){
        Response.RedirectLocation = someLocation;
        Response.StatusCode = (int)HttpStatusCode.MovedPermanently;
        Response.End();
    }
}
</pre>
<p>This doesn't follow the MVC pattern, and the speaker even acknowledges it in the video as it makes unit testing hard. The proper way is to return an ActionResult from the ControllerAction instead. As I happen to have already written a <a href="http://www.stum.de/2008/10/22/permanentredirectresult/">PermanentRedirectResult</a>, my suggestion to improve this code is this:</p>
<pre class="prettyprint lang-cs">
public ActionResult Details(int id)
{
    //snipped some parts
    var enforcedResult = EnforceCanonicalUrl(jobAd.DetailsRouteValues());
    // As View and enforcedResult have different types, I cannot use the ?? operator
    if(enforcedResult != null) return enforcedResult;
    return View(jobAd);
}

private PermanentRedirectResult EnforceCanonicalUrl(RouteValueDictionary routeValues)
{
    if(someCheckFails){
        return new PermanentRedirectResult(canonicalPathAndQuery);
    } else {
       return null;
    }
}
</pre>
<p>So I changed the return type of the controller action to ActionResult instead of ViewResult, and I gave EnforceCanonicalUrl a return type. This function now either returns null or a PermanentRedirectResult, and the controller action now checks for it. There are of course more ways to refine it, but it is in line with the ASP.net MVC pattern of having Controller Actions return ActionResults instead of modifying the Response directly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stum.de/2010/03/28/a-slight-nitpickimprovement-for-tekpubs-video-about-asp-net-mvc-routing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Have a WebForms Open Source Project? Want Tekpub&#8217;s ASP.net MVC 2 Series for free?</title>
		<link>http://www.stum.de/2010/01/06/asp-net-mvc-giveaway/</link>
		<comments>http://www.stum.de/2010/01/06/asp-net-mvc-giveaway/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 01:51:39 +0000</pubDate>
		<dc:creator>mstum</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[asp.net mvc]]></category>
		<category><![CDATA[tekpub]]></category>

		<guid isPermaLink="false">http://www.stum.de/?p=623</guid>
		<description><![CDATA[Okay, here is a little experiment. No idea if it works, but one can try Are you an Open Source Developer, working on a WebForms project? Did you ever ask yourself "Is this really the best way to do this"? Or were you ever curious about ASP.net MVC and just never got around to do [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, here is a little experiment. No idea if it works, but one can try <img src='http://www.stum.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Are you an Open Source Developer, working on a WebForms project? Did you ever ask yourself "Is this really the best way to do this"? Or were you ever curious about ASP.net MVC and just never got around to do it? Or would you just like to compare ASP.net MVC to what you know about WebForms?</p>
<p>I'm giving away one (1) coupon for <a href="http://tekpub.com/preview/aspmvc">TekPub's ASP.net MVC 2 video series</a> - a US$ 28.00 value! What I want in return? Not much - I just want to see that you are an Open Source developer working on a WebForms project. I don't care if you use SourceForge, CodePlex, GitHub, Google Code or your own website. I don't care if it's MS-PL, GPL, MIT. I don't care if you have 1 or 1 Million users. I don't care if it's for pharmaceutical project management or tracking water quality in New Zealand. <strong>Update:</strong> TekPub decided to <a href="http://twitter.com/tekpub/status/7441896170">throw in four (4) additional coupons</a>. Thanks guys!</p>
<p><strong>Criteria</strong></p>
<ul>
<li>ASP.net WebForms project - any version of .net from 1.0 to 4.0 or Mono</li>
<li>Open Source under an <a href="http://www.opensource.org/licenses">OSI License</a></li>
<li>Code must be downloadable freely and without sign up (having to use a Source Control Client is acceptable)</li>
<li>Project must be working - it doesn't need to be mature, finished and polished, but it needs to be something one could download and actually run</li>
<li>Project Owner or Contributor must add a link and a valid e-Mail to the comments of this article</li>
<li>Only one Entry per project - multiple entries will be filtered to only count once</li>
<li>Deadline: Friday, January 15 2010, 8 pm <a href="http://www.timeanddate.com/library/abbreviations/timezones/na/pst.html">PST</a></li>
</ul>
<p><strong>What does "Code must be downloadable" mean?</strong><br />
An open source project needs source code - there are a few projects out there that are in a "Preview" state where the demo-app and project site is up, but the source code is listed as "coming soon"... Your code needs to be downloadable, without having to sign up for any site. It's okay if it's read-only and it's okay if I have to use a source control client to download it (e.g., svn export, git clone...) and it's okay if it's .rar, .tar.bz2, .zip, as a bunch of single files or in any other common format.</p>
<p><strong>What is a "working project"?</strong><br />
This is kind of a fuzzy and unspecific point, I agree. Working does not mean it has to be fully functional, mature and finished. It just means that it's core functionality should be implemented to a point one can actually use your project - for example, a project management system should be able to manage a project, but if e-Mail notification doesn't work and if your CSS is still a  "High Contrast Hot Dog Stand to see which Elements actually apply", that's fine.</p>
<p>I mainly have that rule because I want to reach out to people who really use WebForms.</p>
<p><strong>No Obligations from your side</strong><br />
Should you win, you have no obligation towards me to actually to anything with ASP.net MVC. You do not have to change your existing project and you do not have to create a new (Open or Closed Source) MVC Project. This is not a Crusade initiated by me, I just want to give a WebForms developer a chance to take a deep dive into MVC - you draw your own conclusions and make your own decisions after that.</p>
<p><strong>Fine Print</strong><br />
<small>Disclaimer: I'm not affiliated with TekPub, Microsoft or anyone else - I'm just doing this as an experiment and because I'm curious if there's OSS WebForms Projects whose contributors are interested in ASP.net MVC. Your e-Mail address will only to pick a winner and (that's how WordPress work) to resolve a <a href="http://en.gravatar.com/">Gravatar</a>. It will not be published or shared with anyone else, <em>except with TekPub if you win one of the 4 coupons they give away</em>. You will need to create a free account with TekPub if you win. No purchase necessary. I reserve the right to end this Giveaway early or without selecting a winner.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.stum.de/2010/01/06/asp-net-mvc-giveaway/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Loading a Type specified in web.config, for example a Ninject Module</title>
		<link>http://www.stum.de/2009/12/30/loading-a-type-specified-in-web-config-for-example-a-ninject-module/</link>
		<comments>http://www.stum.de/2009/12/30/loading-a-type-specified-in-web-config-for-example-a-ninject-module/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 00:13:27 +0000</pubDate>
		<dc:creator>mstum</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[asp.net mvc]]></category>
		<category><![CDATA[ninject]]></category>

		<guid isPermaLink="false">http://www.stum.de/?p=610</guid>
		<description><![CDATA[Yesterdays article about having your own configuration section in web.config included the option injectionModule: &#60;myApp injectModule="MyApp.MyAppTestNinjectModule"> The reason I am doing that is because I use Ninject 2 to do dependency injection on my ASP.net MVC 2 app.. Basically I have multiple database backends for my application and the TestNinjectModule implements an in-memory List so [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterdays article about having <a href="http://www.stum.de/2009/12/28/having-a-nested-configuration-section-in-web-config/">your own configuration section in web.config</a> included the option injectionModule:</p>
<pre class="prettyprint lang-cs">
&lt;myApp injectModule="MyApp.MyAppTestNinjectModule">
</pre>
<p>The reason I am doing that is because I use <a href="http://github.com/enkari/ninject">Ninject 2</a> to do <a href="http://codeclimber.net.nz/archive/2009/08/14/how-to-use-ninject-2-with-asp.net-mvc.aspx">dependency injection on my ASP.net MVC</a> 2 app.. Basically I have multiple database backends for my application and the TestNinjectModule implements an in-memory List so that I can develop the application without caring about data persistence yet.</p>
<p>Ninject uses so called Modules that specify the bindings. I have two modules, and my Test Module looks like this:</p>
<pre class="prettyprint lang-cs">
public class MyAppTestNinjectModule : NinjectModule
{
    public override void Load()
    {
        // As the Test Repositories usually use internal Lists, they need to be Singleton
        Bind&lt;IProjectRepository>().To&lt;TestProjectRepository>().InSingletonScope();
        Bind&lt;INoteRepository>().To&lt;TestNoteRepository>().InSingletonScope();
    }
}
</pre>
<p>So everytime Ninject sees IProjectRepository, it knows that it should give me the class <code>TestProjectRepository</code>. (Bonus Tip: When using List&lt;T&gt; as data storage, use InSingletonScope to make sure one instance is shared throughout the entire Application) My second Ninject module looks identical, except that I use MSSqlProjectRepository.</p>
<p>I wanted to have this configurable so that I can easily change between them or add more. Previously, creation of the Kernel (CreateKernel in global.asax) looked like this:</p>
<pre class="prettyprint lang-cs">
protected override IKernel CreateKernel()
{
    return new StandardKernel(new MyAppTestNinjectModule());
}
</pre>
<p>See that call to <code>new MyAppTestNinjectModule()</code>? If I want to change it, I need to recompile and redeploy the App.</p>
<p>The change itself is straight-forward if you know a bit of reflection. Here is what we need to do:</p>
<ol>
<li>Get the name of the Class as a string</li>
<li>Find the <a href="http://msdn.microsoft.com/en-us/library/system.type.aspx">Type</a> that has this name</li>
<li>Instantiate it</li>
<li>Pass the instance to the StandardKernel constructor</li>
</ol>
<p>Here is the overly commented code to do that:</p>
<pre class="prettyprint lang-cs">
protected override IKernel CreateKernel()
{
    // MyAppSettings is the class that reads the setting from
    // web.config
    string moduleName = MyAppSettings.InjectModule;

    // Type.GetType takes a string and tries to find a Type with
    // the *fully qualified name* - which includes the Namespace
    // and possibly also the Assembly if it's in another assembly
    Type moduleType = Type.GetType(moduleName);

    // If Type.GetType can't find the type, it returns Null
    NinjectModule module;
    if (moduleType != null)
    {
        // Activator.CreateInstance calls the parameterless constructor
        // of the given Type to create an instace. As this returns object
        // you need to cast it to the desired type, NinjectModule
        module = Activator.CreateInstance(moduleType) as NinjectModule;
    }
    else
    {
        // If the Type was not found, you need to handle that. You could instead
        // initialize Module through some default type, for example
        // module = new MyAppDefaultNinjectModule();
        // or error out - whatever suits your needs
        throw new MyAppConfigException(
             string.Format("Could not find Type: '{0}'", moduleName),
             "injectModule");
    }

    // As module is an instance of a NinjectModule (or derived) class, we
    // can use it to create Ninject's StandardKernel
    return new StandardKernel(module);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.stum.de/2009/12/30/loading-a-type-specified-in-web-config-for-example-a-ninject-module/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Having a nested Configuration Section in web.config</title>
		<link>http://www.stum.de/2009/12/28/having-a-nested-configuration-section-in-web-config/</link>
		<comments>http://www.stum.de/2009/12/28/having-a-nested-configuration-section-in-web-config/#comments</comments>
		<pubDate>Mon, 28 Dec 2009 11:15:00 +0000</pubDate>
		<dc:creator>mstum</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[asp.net mvc]]></category>

		<guid isPermaLink="false">http://www.stum.de/?p=602</guid>
		<description><![CDATA[I'm currently working on an ASP.net Application for myself, and I was thinking about Configuration. I wanted to use web.config as this is the proper way, but I was unsure what the best way is. I did not want to use appSettings as I feel my own "block" is just more tidy. Here is how [...]]]></description>
			<content:encoded><![CDATA[<p>I'm currently working on an ASP.net Application for myself, and I was thinking about Configuration. I wanted to use web.config as this is the proper way, but I was unsure what the best way is. I did not want to use appSettings as I feel my own "block" is just more tidy. Here is how I want the actual configuration to look like:</p>
<pre class="prettyprint lang-xml">
&lt;myApp injectModule="MyApp.MyAppTestNinjectModule">
  &lt;localeSettings longDateFormat="MM/dd/yyyy HH:mm:ss" />
&lt;/myApp>
</pre>
<p>So I have "myApp" as my main element, with an attribute "injectModule" and a child element "localeSettings". Child Elements allow me to group my settings even more, as I could have in theory dozens of settings, and having them all as attributes to the main myApp-element is messy.</p>
<p>Now, in order to use the myApp element, I need to tell .net about it in the &lt;configSections&gt; section of the web.config. There are two options: section and sectionGroup. I thought that sectionGroup is the correct one, but sectionGroups cannot have attributes, only child Elements. So they are just containers. On the other hand, sections can have attributes and child elements. I don't exactly know why one would use sectionGroup, but I haven't investigated on this too much as it was unsuitable.</p>
<p>So we need to create a section by adding this to the configSections xml element:</p>
<pre class="prettyprint lang-xml">
&lt;section name="myApp" type="MyApp.MyAppConfigurationSection"/>
</pre>
<p>What does this do? It tells ASP.net that we will have an xml Element called myApp, and that this is handled though the MyApp.MyAppConfigurationSection Class. How does this class look like?</p>
<pre class="prettyprint lang-cs">
public class MyAppConfigurationSection : ConfigurationSection
{
    private static ConfigurationPropertyCollection _properties;
    private static ConfigurationProperty _propInjectModule;

    static MyAppConfigurationSection()
    {
        _propInjectModule = new ConfigurationProperty("injectModule", typeof (string),
                                                      "MyApp.MyAppNinjectModule",
                                                      ConfigurationPropertyOptions.None);
        _properties = new ConfigurationPropertyCollection { _propInjectModule };
    }

    protected override ConfigurationPropertyCollection Properties
    {
        get
        {
            return _properties;
        }
    }

    public string InjectModule
    {
        get { return this[_propInjectModule] as string; }
        set { this[_propInjectModule] = value; }
    }
}
</pre>
<p>Whoa, scary... But let's look at this piece by piece. First of all, your class inherits from ConfigurationSection. This is the base class in the .net Framework to represent a section.</p>
<p>We start by defining a ConfigurationProperty named _propInjectModule and initializing it in the static constructor. The four parameters to the new ConfigurationProperty constructor are:</p>
<ol>
<li>The name of the attribute/property as it appears in the web.config later</li>
<li>The Type of the property</li>
<li>The default value - this is important if the parameter is not set in the web.config</li>
<li>Options for this Attribute. I have not checked what IsKey and IsDefaultCollection do, but if IsRequired is set then it <b>has</b> to be set in the web.config</li>
</ol>
<p>So in a nutshell, _propInjectModule is a string that defaults to MyApp.MyAppNinjectModule and is represented in the web.config as injectModule.</p>
<p>The ConfigurationPropertyCollection is needed by .net for some internal plumbing I guess - I haven't checked on it's exact purpose.</p>
<p>Finally, we have the <code>public string InjectModule</code> Property. This is used to access the actual value of the Property. If it's not set in the web.config, the Default value is returned instead. As this is using the Indexer, I'm guessing that this is why the _properties is important.</p>
<p>So, how do we use it? There are multiple options, but I found having a static function most useful:</p>
<pre class="prettyprint lang-cs">
public static MyAppConfigurationSection GetMyAppConfig()
{
    var result = WebConfigurationManager.GetWebApplicationSection("myApp") as MyAppConfigurationSection;
    return result ?? new MyAppConfigurationSection();
}
</pre>
<p>This will try to get the myApp Section of the web.config. If this returns null (i.e. if there is none), then it will just initialize a new instance of the class so that we get it in any case. This works because we have default values for all Properties (Well, there is only one for now). If you want to have required Properties, you possibly need to do something harsh on that.</p>
<p>Okay, so try accessing <code>MyAppConfigurationSection.GetMyAppConfig().InjectModule</code> and you should get either the Default Value of "MyApp.MyAppNinjectModule" or whatever you have specified in the <code>&lt;myApp injectModule="MyApp.MyAppTestNinjectModule"></code> element of your web.config.</p>
<p>So far, so good. But what about the nested localeSettings element? If you just add it to the web.config, you should get an error message explaining that it couldn't parse this element. Let's wire it up.</p>
<p>If you want child elements to a ConfigurationSection, you have to use a ConfigurationElement. I do not exactly know what the real difference between a Section and an Element is and why we need three different layers of nesting (sectionGroup - section - element), but I'm sure the Framework designers had something in mind here.</p>
<p>Let us first implement the .net Class for the ConfigurationElement:</p>
<pre class="prettyprint lang-cs">
public class MyAppLocaleSettingsElement : ConfigurationElement
{
    private readonly static ConfigurationPropertyCollection _properties;
    private readonly static ConfigurationProperty _propLongDateFormat;

    protected override ConfigurationPropertyCollection Properties
    {
        get
        {
            return _properties;
        }
    }

    static MyAppLocaleSettingsElement()
    {
        _propLongDateFormat = new ConfigurationProperty("longDateFormat", typeof (string),
                                                        "ddd, MMM dd, yyyy HH:mm",
                                                        ConfigurationPropertyOptions.None);
        _properties = new ConfigurationPropertyCollection { _propLongDateFormat };
    }

    public string LongDateFormat
    {
        get { return this[_propLongDateFormat] as string; }
        set { this[_propLongDateFormat] = value; }
    }
}
</pre>
<p>As you see, this works exactly the same as a ConfigurationSection: We have a string property with a Default Value and a public Property.</p>
<p>What we need to do now is to wire it into the MyAppConfigurationSection class. Here are the changes to the class:</p>
<pre class="prettyprint lang-cs">
public class MyAppConfigurationSection : ConfigurationSection
{
    private readonly static ConfigurationProperty _propLocaleSettings;
    static MyAppConfigurationSection()
    {
        _propLocaleSettings = new ConfigurationProperty("localeSettings", typeof(MyAppLocaleSettingsElement),
                                                        new MyAppLocaleSettingsElement(),
                                                        ConfigurationPropertyOptions.None);
        _properties = new ConfigurationPropertyCollection { _propInjectModule, _propLocaleSettings };
    }
    public MyAppLocaleSettingsElement LocaleSettings
    {
        get { return this[_propLocaleSettings] as MyAppLocaleSettingsElement; }
    }
}
</pre>
<p>We created a new property that is represented through the "localeSettings" element in the xml. For the default value, I am returning a new instance - again, this works because I specified default Values. Finally, I have a new Property LocaleSettings which exposes the child element through the getter.</p>
<p>To access this, we can do <code>MyAppConfigurationSection.GetMyAppConfig().LocaleSettings.LongDateFormat</code> and either retrieve the default value or the one specified in the web.config.</p>
<p>Here is a recommendation though: I would recommend adding a separate Settings class that your application uses. This class sits between the MyAppConfigurationSection class and your application (it serves as a <a href="http://en.wikipedia.org/wiki/Facade_Pattern">Facade</a>). Why? To make sure that you can change your configuration structure without making too many breaking changes. Maybe I decide that "injectModule" shouldn't be an attribute to the myApp element and instead I want to add a child Element? Or maybe I don't want to use web.config at all and instead use a SQL Server database or a Web Service? Or maybe all of a sudden I decided that injectModule is a required Parameter, which means I now need to handle the case where the user hasn't added a myApp element to his web.config?</p>
<p>Here is one example of Settings class:</p>
<pre class="prettyprint lang-cs">
public static class MyAppSettings
{
    private static readonly MyAppConfigurationSection Config;

    static MyAppSettings()
    {
        Config = MyAppConfigurationSection.GetMyAppConfig();
    }

    public static class LocaleSettings
    {
        public static string LongDateFormat
        {
            get
            {
                return Config.LocaleSettings.LongDateFormat;
            }
        }
    }

    public static string InjectModule
    {
        get { return Config.InjectModule; }
    }
}
</pre>
<p>I'm using nested classes to group it, but I can now change the MyAppConfigurationSection class (or completely remove it) and only need to do changes in the MyAppSettings Facade-class without affecting the rest of my application.</p>
<p>If you really want to dig deep into this, check out these three links (thanks to <a href="http://stackoverflow.com/questions/1968592/accessing-an-attribute-on-a-configsection-in-a-web-config/1968621#1968621">marc_s</a>):</p>
<ul>
<li><a href="http://www.codeproject.com/KB/dotnet/mysteriesofconfiguration.aspx">Unraveling the mysteries of .NET 2.0 configuration</a></li>
<li><a href="http://www.codeproject.com/KB/dotnet/mysteriesofconfiguration2.aspx">Decoding the mysteries of .NET 2.0 configuration</a></li>
<li><a href="http://www.codeproject.com/KB/dotnet/mysteriesofconfiguration3.aspx">Cracking the mysteries of .NET 2.0 configuration</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.stum.de/2009/12/28/having-a-nested-configuration-section-in-web-config/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Blog Software in the .net world &#8211; still sad</title>
		<link>http://www.stum.de/2009/04/29/blog-software-in-the-net-world-still-sad/</link>
		<comments>http://www.stum.de/2009/04/29/blog-software-in-the-net-world-still-sad/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 19:11:10 +0000</pubDate>
		<dc:creator>mstum</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[My Tools]]></category>
		<category><![CDATA[asp.net mvc]]></category>

		<guid isPermaLink="false">http://www.stum.de/?p=471</guid>
		<description><![CDATA[I blogged in November 2007 about Open Source and .net, also talking about blog software. While I am happy to report that the general landscape looks a lot nicer now in April 2009, I am still sad by the state of blog software. Back in 2007, I complained about complicated setup processes, the inability to [...]]]></description>
			<content:encoded><![CDATA[<p>I <a href="http://www.stum.de/2007/11/21/open-source-and-net-not-really-an-ideal-partnership/">blogged in November 2007</a> about Open Source and .net, also talking about blog software. While I am happy to report that the general landscape looks a lot nicer now in April 2009, I am still sad by the state of blog software.<br />
Back in 2007, I complained about complicated setup processes, the inability to run in common configurations (aka. "Medium Trust") and generally low quality. 3 Weeks ago, I've had to setup another .net blog, so I looked at the landscape again.</p>
<p>It has improved. But not that much. Software like WordPress is still miles ahead, and I am not even talking that much about functionality here. I'm talking about some fundamental things like ease of installation. Or about the fact that Settings in the WordPress Control Panel are actually *explained*. Or the fact that I can put in RAW HTML into my postings WITHOUT WordPress destroying it. Sure, if I switch between WYSIWYG and HTML View, there may be a breaking conversations when using funky HTML, but if I stay in HTML, it just works. If I put in Garbage, then WP will output garbage.</p>
<p>I'm not even talking about the Theme and Plugin momentum that WordPress has. I am really just talking about a Software that is easy to install, runs on my hosted server and allows pushing of some Content. Is that asked too much? Sadly, yes. I don't want to be too harsh, hence I will not name the tools I've tried (there were 4). I don't want to blame developers who are really trying to do something for issues that lie within the framework. The ASP.net infrastructure has a lot of advantages over PHP, but as good as stuff like Web.config, Medium Trust and SQL Connection Strings is, it's adding more complexity that developers seem to not try to take away from the end user.</p>
<p>I don't know if this is the fault of the ASP.net Webforms model or if the .net OSS Community is smaller or whatever. I've now decided to tackle something that I have on my ToDo-List since writing that post in November 2007, I've decided to write my own blog software. I want to encounter the problems that the people who are creating it have, I want to run it in a production environment (Dogfooding, so to say). The recent release of <a href="http://www.asp.net/mvc/">ASP.net MVC</a> was the final bit that removed all excuses for not doing it.</p>
<p>I will run into a lot of issues. I want to learn and use <a href="http://en.wikipedia.org/wiki/Test-driven_development">TDD</a>, <a href="http://en.wikipedia.org/wiki/Dependency_Injection">DI</a> and <a href="http://en.wikipedia.org/wiki/Object-relational_mapping">ORM</a>, and I have experience in none. I will do a lot of refactoring, and a lot of breaking changes and braindead mistakes. But I don't want to be a complainer anymore when I have the opportunity to change it.</p>
<p>I don't want to announce too much because it's still in the early stages, but it will be open source (<a href="http://www.opensource.org/licenses/ms-pl.html">Ms-PL</a>) and hosted on <a href="http://www.codeplex.com/">Codeplex</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stum.de/2009/04/29/blog-software-in-the-net-world-still-sad/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Rick Version 02 &#8211; Building a custom ActionResult to perform a HTTP 301 redirect</title>
		<link>http://www.stum.de/2008/12/14/rick-version-02-building-a-custom-actionresult-to-perform-a-http-301-redirect/</link>
		<comments>http://www.stum.de/2008/12/14/rick-version-02-building-a-custom-actionresult-to-perform-a-http-301-redirect/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 19:13:56 +0000</pubDate>
		<dc:creator>mstum</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[My Tools]]></category>
		<category><![CDATA[Rick]]></category>
		<category><![CDATA[asp.net mvc]]></category>

		<guid isPermaLink="false">http://www.stum.de/?p=380</guid>
		<description><![CDATA[Yesterday I've made the very first version of Rick, a URL Shortening Service in ASP.net MVC, and today I've made the first addition. In Version 02 of Rick, I have added a custom ActionResult to perform a HTTP 301 redirect instead of the default HTTP 302 one. You can get the Source Code on http://www.codeplex.com/rick, [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I've made the <a href="http://www.stum.de/2008/12/14/rick-url-shortening-service-an-aspnet-mvc-learning-project/">very first version of Rick</a>, a URL Shortening Service in ASP.net MVC, and today I've made the first addition.</p>
<p>In Version 02 of Rick, I have added a custom ActionResult to perform a HTTP 301 redirect instead of the default HTTP 302 one. You can get the Source Code on <a href="http://www.codeplex.com/rick">http://www.codeplex.com/rick</a>, and you can watch the tutorial video on Vimeo. Topics include a short overview of HTTP 301 vs. 302 and how to actually create a custom ActionResult.</p>
<p><object width="640" height="483" data="http://vimeo.com/moogaloop.swf?clip_id=2524188&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1" type="application/x-shockwave-flash"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=2524188&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1" /></object><br />
<a href="http://vimeo.com/2524188?pg=embed&amp;sec=2524188">Rick Version 02 - Building a custom ActionResult to perform a HTTP 301 redirect</a> from <a href="http://vimeo.com/user894920?pg=embed&amp;sec=2524188">Michael Stum</a> on <a href="http://vimeo.com?pg=embed&amp;sec=2524188">Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stum.de/2008/12/14/rick-version-02-building-a-custom-actionresult-to-perform-a-http-301-redirect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rick URL Shortening Service &#8211; an ASP.net MVC learning project</title>
		<link>http://www.stum.de/2008/12/14/rick-url-shortening-service-an-aspnet-mvc-learning-project/</link>
		<comments>http://www.stum.de/2008/12/14/rick-url-shortening-service-an-aspnet-mvc-learning-project/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 02:56:15 +0000</pubDate>
		<dc:creator>mstum</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[My Tools]]></category>
		<category><![CDATA[Rick]]></category>
		<category><![CDATA[asp.net mvc]]></category>

		<guid isPermaLink="false">http://www.stum.de/?p=377</guid>
		<description><![CDATA[All right, I said I wanted to start learning ASP.net MVC, and I did make some progress A few weeks ago, I was talking about creating a project called Écriture, a Twitter clone that companies can deploy internally. That project is still in the plans, and when I was creating the "Wishlist" (Or Product Backlog, [...]]]></description>
			<content:encoded><![CDATA[<p>All right, I said I wanted to start learning ASP.net MVC, and I did make some progress <img src='http://www.stum.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  A few weeks ago, I was talking about creating a project called <a href="http://www.stum.de/2008/10/19/ecriture-a-new-way-of-company-wide-instant-messaging/">Écriture</a>, a Twitter clone that companies can deploy internally. That project is still in the plans, and when I was creating the "Wishlist" (Or Product Backlog, as the SCRUM guys like to call it) for Écriture, eventually I realized that I wanted a URL Shortening service as well, since in many corporate intranets, URLs can be really long, and using tinyurl, is.gd and all the other services have some confidentiality concerns (hint: Using tinyurl to shorten "company.internal/documents/marketing/unaccouncedproduct.htm" is possibly not very smart).</p>
<p>I wanted to kill three birds with one stone, so I decided to make this a standalone project. The three birds are 1. the actual URL shortening Service, 2. a project where I can play with all the newest technologies, 3. a project that allows me to create some tutorial videos.</p>
<p>The name of the Project is "Rick", and it's source code is hosted on CodePlex, at <a href="http://www.codeplex.com/rick">http://www.codeplex.com/rick</a></p>
<p>Version 01 was just released, and it actually fully works already: You can put in a long URL, get a short URL back, put that short URL in a browser, and get redirected to the original URL. And the best of all: I have created a Tutorial video for that, which you can watch online or download (download requires free registration with <a href="http://www.vimeo.com/">Vimeo</a>). Granted, Version 01 is ugly, has no error handling and lacks a lot of features, but I am actually going to improve it over the next few weeks, making it more robust and I also plan to add more technologies to it, for example Windows Azure or Silverlight.</p>
<p>For your convenience, here is the video:</p>
<p><object width="640" height="483" data="http://vimeo.com/moogaloop.swf?clip_id=2517727&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1" type="application/x-shockwave-flash"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=2517727&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00adef&amp;fullscreen=1" /></object><br />
<a href="http://vimeo.com/2517727?pg=embed&amp;sec=2517727">Rick Version 01 - Building a URL Shortening Service in ASP.net MVC</a> from <a href="http://vimeo.com/user894920?pg=embed&amp;sec=2517727">Michael Stum</a> on <a href="http://vimeo.com?pg=embed&amp;sec=2517727">Vimeo</a>.</p>
<p>Please let me know what you think and what you would like to see in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.stum.de/2008/12/14/rick-url-shortening-service-an-aspnet-mvc-learning-project/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PermanentRedirectResult &#8211; a 301 HTTP Redirect for ASP.net MVC</title>
		<link>http://www.stum.de/2008/10/22/permanentredirectresult/</link>
		<comments>http://www.stum.de/2008/10/22/permanentredirectresult/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 22:46:52 +0000</pubDate>
		<dc:creator>mstum</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[My Tools]]></category>
		<category><![CDATA[asp.net mvc]]></category>

		<guid isPermaLink="false">http://www.stum.de/?p=247</guid>
		<description><![CDATA[For a little project to learn ASP.net MVC, I needed my Controller to return a HTTP 301 Redirect. Unfortunately, just calling "return Redirect(url)" returns a HTTP 302 instead of a 301. After checking on the MVC Forums, there seems to be no "official" way to perform a 301 Redirect in a Controller. Of course, you [...]]]></description>
			<content:encoded><![CDATA[<p>For a little project to learn ASP.net MVC, I needed my Controller to return a <a href="http://en.wikipedia.org/wiki/HTTP_301">HTTP 301 Redirect</a>. Unfortunately, just calling "return Redirect(url)" returns a <a href="http://en.wikipedia.org/wiki/HTTP_302">HTTP 302</a> instead of a 301. After checking on the <a href="http://forums.asp.net/p/1337938/2700733.aspx">MVC Forums</a>, there seems to be no "official" way to perform a 301 Redirect in a Controller. Of course, you can always modify the Response directly, but I decided that returning an ActionResult would be cleaner (and I think that makes it easier to unit test), even though it is essentially doing exactly that, setting a custom Status Code and Redirect Location.</p>
<p>So here is my little PermanentRedirectResult:</p>
<pre class="prettyprint lang-cs">
public class PermanentRedirectResult : ActionResult
{
    public string Url { get; set; }

    public PermanentRedirectResult(string url)
    {
        if (string.IsNullOrEmpty(url))
        {
            throw new ArgumentException("url is null or empty", "url");
        }
        this.Url = url;
    }

    public override void ExecuteResult(ControllerContext context)
    {
        if (context == null)
        {
            throw new ArgumentNullException("context");
        }
        context.HttpContext.Response.StatusCode = 301;
        context.HttpContext.Response.RedirectLocation = Url;
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.stum.de/2008/10/22/permanentredirectresult/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
