<?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>hexadecimal &#187; ASP.NET MVC</title>
	<atom:link href="http://blog.hexadecimal.se/category/asp-net-mvc/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hexadecimal.se</link>
	<description>Being creative in the digital age</description>
	<lastBuildDate>Fri, 07 May 2010 12:06:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>This thing called Oxite</title>
		<link>http://blog.hexadecimal.se/2009/05/02/this-thing-called-oxite/</link>
		<comments>http://blog.hexadecimal.se/2009/05/02/this-thing-called-oxite/#comments</comments>
		<pubDate>Sat, 02 May 2009 14:56:16 +0000</pubDate>
		<dc:creator>q</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.hexadecimal.se/2009/05/02/ThisThingCalledOxite.aspx</guid>
		<description><![CDATA[I’ve been fiddling around with Oxite recently. Although I find it highly interesting and a lot of fun, it being based on ASP.NET MVC and all, it’s not yet mature enough to be an out-of-the-box blogging engine. None of the shortcomings are show-stoppers as such, and it’s not intended to compete with the major actors [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve been fiddling around with <a href="http://oxite.net/">Oxite</a> recently. Although I find it highly interesting and a lot of fun, it being based on ASP.NET MVC and all, it’s not yet mature enough to be an out-of-the-box blogging engine.</p>
<p>None of the shortcomings are show-stoppers as such, and it’s not intended to compete with the major actors out there—yet.</p>
<p>Most of the issues with Oxite are little things like lack of ready-made themes, plug-ins, statistics and the ability to post images and videos to the blog via the <a href="http://en.wikipedia.org/wiki/MetaWeblog">metaweblog API</a>, instead requiring the user to mess around with FTP settings.</p>
<p>Despite the shortcomings, I’m quite excited. I’ve already picked it apart and put most of it back together (hence the lack of blog posts the past couple of weeks).</p>
<p>The first thing I did was create my own theme, tweak the styles and add menus and such. This required a whole bunch of CSS coding and some actual C# plumbing.</p>
<p><a href="http://www.hexadecimal.se/content/binary/WindowsLiveWriter/ThisthingcalledOxite_E7AC/oxite-theme_2.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="oxite-theme" border="0" alt="oxite-theme" src="http://www.hexadecimal.se/content/binary/WindowsLiveWriter/ThisthingcalledOxite_E7AC/oxite-theme_thumb.png" width="519" height="419" /></a> </p>
<p>What struck me as a bit quaint, was that even though you can add your own content pages (applause!), those pages don’t automatically appear in any menus or anything. You actually need to hand-edit the C# code to add links to those pages in the menus.</p>
<p>One thing that I really like about dasBlog, is that it runs without&#160; a relational database engine, such as Microsoft SQL Server, or MySQL. It operates purely on disk-based XML files. That right there just cut off 50% of the hosting fee.</p>
<p>Luckily, Oxite has a lot of extension points. Adding a data provider that is based on XML files instead of Microsoft SQL Server, <em>shouldn’t</em> be too much of a problem.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:c34cc95b-3857-484d-9c0f-b396b7e28f91" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/ASP.NET+MVC" rel="tag">ASP.NET MVC</a>,<a href="http://technorati.com/tags/Coding" rel="tag">Coding</a>,<a href="http://technorati.com/tags/Internet" rel="tag">Internet</a>,<a href="http://technorati.com/tags/Blogging" rel="tag">Blogging</a></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.hexadecimal.se/2009/05/02/this-thing-called-oxite/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Deploying ASP.NET MVC applications on an Apache web server</title>
		<link>http://blog.hexadecimal.se/2009/04/09/deploying-asp-net-mvc-applications-on-an-apache-web-server/</link>
		<comments>http://blog.hexadecimal.se/2009/04/09/deploying-asp-net-mvc-applications-on-an-apache-web-server/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 14:35:43 +0000</pubDate>
		<dc:creator>q</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Internet]]></category>

		<guid isPermaLink="false">http://www.hexadecimal.se/2009/04/09/DeployingASPNETMVCApplicationsOnAnApacheWebServer.aspx</guid>
		<description><![CDATA[I struggled a bit to get the live demo up and running for my previous article on ASP.NET MVC because my hosting provider runs on the Apache web platform, which wasn’t all too keen on the MVC URL rewriting. One of the problems is that on Apache (same as on IIS6), the document being served [...]]]></description>
			<content:encoded><![CDATA[<p>I struggled a bit to get the <a href="http://www.wheresmymovie.net/home.aspx" target="_blank">live demo</a> up and running for my <a href="http://www.hexadecimal.se/2009/04/09/ASPNETMVCRULESSURPREME.aspx" target="_blank">previous article</a> on <a href="http://www.asp.net/mvc" target="_blank">ASP.NET MVC</a> because my hosting provider runs on the Apache web platform, which wasn’t all too keen on the MVC URL rewriting. </p>
<p>One of the problems is that on Apache (same as on IIS6), the document being served has to have a particular file extension in order for the <em>mod_aspdotnet</em> module to be invoked at all. Since the URL scheme in ASP.NET MVC by default does not have an extension, ie. www.wheresmymovie.net/home/about, this results in a 404 generated in Apache before the ASP.NET module ever gets invoked, and thus before any URL rewriting occurs.</p>
<p>If you have direct access to the server configuration, you can add a wildcard pattern to the <em>AddHandler </em>directive in the httd.conf file. This has the disadvantage of serving all content (including images and style sheets) through the ASP.NET module. Not to mention that it requires you to have direct access to the httpd.conf file, which you might not have in a shared hosting environment.</p>
<p>A better solution is to modify the routes in the Global.asax.cs file, and add an extension that the module will intercept, so that the links will look like this: <a href="http://www.wheresmymovie.net/home.aspx/about">http://www.wheresmymovie.net/home.aspx/about</a></p>
<p>The .aspx extension on the controller will do the trick, causing Apache to invoke <em>mod_aspdotnet</em> to serve the page, and then the URL rewriting will kick in. </p>
<p>Here’s a copy of the URL route from Global.asax.cs running on the <a href="http://www.wheresmymovie.net/home.aspx" target="_blank">live sample</a> which is hosted on an Apache web server:</p>
<pre class="brush: csharp" name="code">public static void RegisterRoutes(RouteCollection routes)
{
  routes.IgnoreRoute(&quot;{resource}.axd/{*pathInfo}&quot;);

  routes.MapRoute(
    &quot;Default.aspx&quot;,
    &quot;{controller}.aspx/{action}/{id}&quot;,
    new { controller = &quot;Home&quot;, action = &quot;Index&quot;, id = &quot;&quot; },
    new { controller = @&quot;[^\.]*&quot; }
  );

  routes.MapRoute(
    &quot;Default&quot;,
    &quot;{controller}/{action}/{id}&quot;,
    new { controller = &quot;Home&quot;, action = &quot;Index&quot;, id = &quot;&quot; },
    new { controller = @&quot;[^\.]*&quot; }
  );
}</pre>
<p><em>Big thanks to </em><a href="http://biasecurities.com/blog/2008/how-to-enable-pretty-urls-with-asp-net-mvc-and-iis6/" target="_blank"><em>bia securities</em></a><em>, which is where I got the above code snippet.</em></p>
<p>Note that the “Default.aspx” route, which adds the .aspx extension to the controller comes <em>before</em> the “Default” route. This is so that calls to Html.ActionLink will generate links conforming to this scheme, since it will pick the first in the list.</p>
<p>This is basically the same thing that dasBlog does. It you have a look at the address bar above (this blog runs on dasBlog), you’ll notice that the .aspx extension is there, at the end of the URL routing scheme, which is actually something like {year}/{month}/{day}/{title}.aspx.</p>
<p>If you want pretty URLs and you don’t want the .aspx extension in there, you can either change it to some other extension, like .mvc, and add it to the AddHandler directive in the httpd.conf file. That, or upgrade to IIS7.</p>
<p>For more information about deploying ASP.NET MVC, check out this <a href="http://www.asp.net/learn/mvc/tutorial-08-cs.aspx" target="_blank">great article</a> over at asp.net.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:0bd88b13-5ffb-41dc-b809-5d6b28256352" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Coding" rel="tag">Coding</a>,<a href="http://technorati.com/tags/C%23" rel="tag">C#</a>,<a href="http://technorati.com/tags/Internet" rel="tag">Internet</a>,<a href="http://technorati.com/tags/ASP.NET+MVC" rel="tag">ASP.NET MVC</a>,<a href="http://technorati.com/tags/VS2008" rel="tag">VS2008</a></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.hexadecimal.se/2009/04/09/deploying-asp-net-mvc-applications-on-an-apache-web-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET MVC RULES SURPREME!</title>
		<link>http://blog.hexadecimal.se/2009/04/09/asp-net-mvc-rules-surpreme/</link>
		<comments>http://blog.hexadecimal.se/2009/04/09/asp-net-mvc-rules-surpreme/#comments</comments>
		<pubDate>Thu, 09 Apr 2009 13:12:44 +0000</pubDate>
		<dc:creator>q</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.hexadecimal.se/2009/04/09/ASPNETMVCRULESSURPREME.aspx</guid>
		<description><![CDATA[Seldom do I use all-caps for titles. This time, it’s merited. I’ve been circling around ASP.NET MVC like a suspicious lion for months. Since I don’t work much with web projects, this has slipped down on my priority list in favor of technologies more relevant to my current projects. But since it recently hit official [...]]]></description>
			<content:encoded><![CDATA[<p>Seldom do I use all-caps for titles. This time, it’s merited. I’ve been circling around <a href="http://www.asp.net/" target="_blank">ASP.NET MVC</a> like a suspicious lion for months. Since I don’t work much with web projects, this has slipped down on my priority list in favor of technologies more relevant to my current projects. But since it <a href="http://weblogs.asp.net/scottgu/archive/2009/04/01/asp-net-mvc-1-0.aspx" target="_blank">recently hit official release</a>, I made some time last weekend and got around to it.</p>
<p>The web is a fantastic tool. Plain and simple. With all the new technologies that have been elbowing their way into our lives to make them simpler, easier, faster and richer, the web has never before been such a valuable resource as it is today. One of those technologies that I really like is Silverlight. Another, is ASP.NET MVC.</p>
<p>I cannot lavish enough praise upon this new technology. Because I’d run out of disk space.</p>
<p>There are many levels of programming. You can code in machine-code, for the ultimate control over the computer, or you can point and click for a bit more productivity at the expense of control. ASP.NET MVC has poked up from nowhere right smack in the middle of the two.</p>
<p>To <a href="http://weblogs.asp.net/scottgu/archive/2007/10/14/asp-net-mvc-framework.aspx" target="_blank">quote</a>&#160; The Gu:</p>
<blockquote><p>MVC is a framework methodology that divides an application&#8217;s implementation into three component roles: models, views, and controllers. </p>
<ul>
<li>&quot;Models&quot; in a MVC based application are the components of the application that are responsible for maintaining state.&#160; Often this state is persisted inside a database (for example: we might have a Product class that is used to represent order data from the Products table inside SQL). </li>
<li>&quot;Views&quot; in a MVC based application are the components responsible for displaying the application&#8217;s user interface.&#160; Typically this UI is created off of the model data (for example: we might create an Product &quot;Edit&quot; view that surfaces textboxes, dropdowns and checkboxes based on the current state of a Product object). </li>
<li>&quot;Controllers&quot; in a MVC based application are the components responsible for handling end user interaction, manipulating the model, and ultimately choosing a view to render to display UI.&#160; In a MVC application the view is only about displaying information &#8211; it is the controller that handles and responds to user input and interaction.        <br />One of the benefits of using a MVC methodology is that it helps enforce a clean separation of concerns between the models, views and controllers within an application.&#160; Maintaining a clean separation of concerns makes the testing of applications much easier, since the contract between different application components are more clearly defined and articulated. </li>
</ul>
</blockquote>
<p>I’m a big fan of productivity. And ASP.NET MVC increases productivity like few other web technologies I’ve ever seen. It allows me to do complex things in very little time. It’s also very extensible and comes with full source code, so if I run into a wall, I can simply rewrite the wall to conveniently have a gate in it.</p>
<p>The first thing I did (after I downloaded the ASP.NET MVC kit), was to have a look at a video tutorial. Normally, I’m one of those who gleefully tears off the wrapping and plugs things in and starts pushing buttons without a single thought to the manual. But I was tired and wanted a 5 minute crash course in what it is, and what it does.</p>
<p>I highly recommend you watch that very same video, the “<a href="http://www.asp.net/learn/mvc-videos/video-395.aspx" target="_blank">Creating a movie database tutorial</a>” on <a href="http://www.asp.net">www.asp.net</a>. They say that a picture says more than a thousand words, and a movie with maybe 20 frames per second for twelve minutes and four seconds, must then (obviously) say more than 14,480,000 words. And since I would not think of clogging you down with 14.5 million words, I’ll simply leave you to watch that fantastic introduction to ASP.NET MVC and wait right here while you go have your socks knocked off.</p>
<p>Right, so after I had watched the tutorial (which I highly recommend you do before proceeding any further. Go on, I’ll still be here when you’re done!), I instantly fired up Visual Studio and created my very first MVC web application.</p>
<p>I started to do my own movie database like the tutorial, but quickly got a better idea and opted for a tiny bit of originality. I created a<em> movie site ranking</em> database. A site with a list of online movie sites with ranking. I also found the <a href="http://www.asp.net/mvc/gallery/" target="_blank">ASP.NET MVC design gallery</a> and downloaded a nice enough looking theme to use.</p>
<p>The whole thing took about an hour.&#160; Yep, that’s it, an hour. And that includes the time spent designing the database, going back to the tutorial and Googling for solutions, tweaking the style sheet as well as creating a few icons and graphical elements. And this was my first time using ASP.NET MVC! Imagine what you could be doing nine hours from now, after you have made nine complete and functional websites just like this one! Why … there’s no end to the possibilities!</p>
<p><a href="http://www.hexadecimal.se/content/binary/WindowsLiveWriter/ASP.NETMVCRULESSURPREME_1D22/dude-wheres-my-movie_2.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="dude-wheres-my-movie" border="0" alt="dude-wheres-my-movie" src="http://www.hexadecimal.se/content/binary/WindowsLiveWriter/ASP.NETMVCRULESSURPREME_1D22/dude-wheres-my-movie_thumb.png" width="518" height="419" /></a> </p>
<p>The ASP.NET MVC application I made is complete with user registration, a little news feed (no RSS support), a list of sites with description, commenting, ratings and ranking based on their total scores.</p>
<p><a href="http://www.hexadecimal.se/content/binary/WindowsLiveWriter/ASP.NETMVCRULESSURPREME_1D22/commenting_2.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="commenting" border="0" alt="commenting" src="http://www.hexadecimal.se/content/binary/WindowsLiveWriter/ASP.NETMVCRULESSURPREME_1D22/commenting_thumb.png" width="520" height="422" /></a> </p>
<p>It has a functional administrative back-end to create, update and delete sites, score categories, news and studios (which sites can be affiliated with). The create/edit movie site views have some interesting master-multiple-detail relations with synchronization to remove unselected items and add newly selected items in a many-to-many relationship (the checkboxes and the scores).</p>
<p><a href="http://www.hexadecimal.se/content/binary/WindowsLiveWriter/ASP.NETMVCRULESSURPREME_1D22/admin_4.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="admin" border="0" alt="admin" src="http://www.hexadecimal.se/content/binary/WindowsLiveWriter/ASP.NETMVCRULESSURPREME_1D22/admin_thumb_1.png" width="520" height="427" /></a></p>
<p>When a site is affiliated with a list of studios, their logos appear beneath the site description like this:</p>
<p><a href="http://www.hexadecimal.se/content/binary/WindowsLiveWriter/ASP.NETMVCRULESSURPREME_1D22/studios_2.png"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="studios" border="0" alt="studios" src="http://www.hexadecimal.se/content/binary/WindowsLiveWriter/ASP.NETMVCRULESSURPREME_1D22/studios_thumb.png" width="502" height="290" /></a>&#160; </p>
<p>All that, in an hour!</p>
<p>And it’s all so very easy. Each action you can take on the website, such as create a new movie site, add a comment, and so on are <em>methods </em>on the controller class. Here for instance is the code to route the visitor from the root URL <em>~/ </em>to a view that will render the list of movie sites, sorted by total score:</p>
<pre class="brush: csharp" name="code">public class HomeController : Controller
{
    private MovieSitesDbEntities mEntities =
        new MovieSitesDbEntities();

    //
    // GET: /
    public ActionResult Index()
    {
        var sites = mEntities.SiteSet.
                Include(&quot;Scores&quot;).
                Include(&quot;Scores.ScoreCategory&quot;).
                Include(&quot;Studios&quot;).
                Include(&quot;Comments&quot;).
            OrderByDescending(s =&gt;
                s.Scores.Sum(score =&gt; score.Score)).ToList();

        ViewData.Model = sites;
        return View();
    }
}</pre>
<p>And the contents of the /Views/Home/Index.aspx which contains the code to render that particular view contains simple asp.net syntax like this:</p>
<pre class="brush: xml" name="code">&lt;asp:Content ID=&quot;Content2&quot; ContentPlaceHolderID=&quot;MainContent&quot;
    runat=&quot;server&quot;&gt;

&lt;h1&gt;Movie Site Rankings&lt;/h1&gt;

&lt;% int rankNo = 1;
   foreach (var item in Model) { %&gt;
  &lt;div class=&quot;rating&quot;&gt;
    &lt;div class=&quot;siteDescription&quot;&gt;
      &lt;h2&gt;#&lt;%= rankNo++%&gt;
      &lt;a href=&quot;&lt;%= item.URI %&gt;&quot;&gt;&lt;%= item.Name %&gt;&lt;/a&gt;&lt;/h2&gt;
      &lt;p&gt;
        &lt;img class=&quot;float-left&quot;
          src=&quot;/Content/Screenshots/&lt;%= item.ScreenshotURI %&gt;&quot;
          alt=&quot;Site screenshot&quot; /&gt;
        &lt;%= item.Description %&gt;
      &lt;/p&gt;
...</pre>
<p>&#160;</p>
<p>I’m impressed.</p>
<p><a href="http://www.wheresmymovie.net/home.aspx" target="_blank">Click here to view a live demo of the Movie Site Ranking demo!</a>&#160;</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:ba7a393e-a318-4689-a4d3-f56dcf3698ba" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/Coding" rel="tag">Coding</a>,<a href="http://technorati.com/tags/C%23" rel="tag">C#</a>,<a href="http://technorati.com/tags/Internet" rel="tag">Internet</a>,<a href="http://technorati.com/tags/ASP.NET+MVC" rel="tag">ASP.NET MVC</a>,<a href="http://technorati.com/tags/VS2008" rel="tag">VS2008</a></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.hexadecimal.se/2009/04/09/asp-net-mvc-rules-surpreme/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
