Skip to main content

Posts

Showing posts with the label mvc

OpenRasta vs WCF for RESTful Services

  Not long ago I discovered OpenRasta . If you’re not familiar with it it’s described as a “resource-oriented framework for .NET enabling easy ReST-ful development of websites and services”. After reading Rails 3 in a Nutshell I started looking at .NET a bit differently and have started being envious of the simplicity of Rails. When it comes to REST the ROR guys have definitely approached it the right way and it is baked right into the Rails framework. When it comes to .NET there are a few different approaches you can take to create RESTful services. ASP.NET MVC WCF OpenRasta Other MVC Frameworks Standard HTTP Handlers In this post I’m going to cover how you can implement such a service using WCF and OpenRasta. The goal is to expose a Product as JSON and XML using a RESTful uri. product/1 WCF Approach First let’s have a look at how to do this in WCF Project Structure Just create a standard WCF Service Application Project DataCont...

Securing Controller Actions in ASP.NET MVC for Multi-Tenant Applications

One of the cool things about using the MVC Framework is that you get clean RESTful urls e.g. /Product/Edit/1 This is all well and good but when developing a multi-tenant application which uses a Shared datastore it is extremely important that your controller actions are secure in the sense that the Urls can’t be tampered with. Believe it or not but this level of security is often neglected in a lot of projects or is at the least an afterthought. You could implement in every controller action something like below: public ActionResult Edit( int id) { if (!catalogService.HasAccessToProduct(UserContext.UserId, id)) { HttpContext.Response.Status = "401 Unauthorized" ; HttpContext.Response.StatusCode = 401; Response.End(); } var product = catalogService.GetProductById(id); ViewData.Model = product; return View(); } However ...

Hosting .NET MVC on RackspaceCloud Cloud Sites

Last week I deployed a pet project (pun intended) of mine Borrow a Pet to the RackspaceCloud Cloud Sites environment. So far I’m very pleased with the performance of the site, however I thought I would highlight a few areas you need to be aware of when developing/deploying .NET MVC apps to the Cloud Sites environment as their documentation right now is fairly light.   It should be said that the 24/7 Support team are fantastic, however I found myself having to use them a bit too often for my liking. The technologies/tools/components I used goes like this. .NET MVC for the Presentation Layer LINQ to Entities for the data layer SQL Server 2008 Database Third Party Google Maps Wrapper for GeoCoding Unity for the IoC Container   Medium Trust Believe it or not but in my eight or so years of .NET development I’ve never had to develop with Medium Trust in mind. Boy had I been spoilt. For more details on Medium Trust information go to the...

KandaAlpha DDD Architecture - MVC, Repository, Entity Framework, db4o on Codeplex

Keith Patton has started a CodePlex project called KandaAlpha which I will be contributing to. Original post here The aim of the project is get our feet wet with Visual Studio 2010 Beta 1 and in particular the POCO capabilities of Entity Framework. It's also going to try and demonstrate best practice Domain Driven Design and other associated patterns. db4o has been selected as the persistancy database of choice as it presents a very interesting alternative to the standard RDBMS.

ASP.NET MVC Release Candidate - Upgrade issues - Spec#

First of all, great news that the ASP.NET MVC Release Candidate has finally been released.  Full credit to the team for the hard work on this.  You can get the download here  However this is the first time I have had upgrade issues.  Phil Haack has noted some of the issues here   If like me you have lot's of CTP's and Add-Ins then you might experience some pain in Uninstalling MVC Beta on Vista SP1  This is the list of Add-Ins / CTP's I had to uninstall to get it to work  Spec# PEX Resharper 4.1  Sourcelinks ANTS Profiler 4   Can't say I'm too impressed as it wasted over an hour of my time.  As it turned out Spec# turned out to be the offending culprit, it's forgiveable to have issues with a third party product but a Microsoft one? Guess no-one on the ASP.NET team has Spec# installed. 

GoGrid vs Amazon EC2 - Cloud Hosting Continued

So I've just completed deploying an application to my first GoGrid server, this is the same application as what I've previously deployed to my Amazon EC2 instance . As I mentioned before the application is an ASP.NET MVC  front-end with supporting WCF services running on against a Sql Server Express 2008  Database.   Because I run a Vista development machine I was aware of the fact that running .NET MVC on IIS7.0 outperforms II6.0 with the wildcard ISAPI filter which is what I had to resort to when using my EC2 instance. What I didn't know was by just how much.  On a general note the overall learning curve and time taken to setup the server and then deploy the application was far less than with Amazon EC2. So full credit to Go Grid for the intuitive user interface. Also not having to concern myself with Elastic Block Stores and tracking down the Windows Server Install Disc Snapsh0t to install FTP server was a great help and thing's which have been made unnecessari...

Cloud Hosting - Amazon EC2

style="" > So recently I got the chance to deploy my first application to Amazon EC2.   I've got to say after a little bit of trial and error I think the service is pretty amazing and is definetly the future of web hosting and you sure can't beat the price US $0.125 / Hour which is essentially US $90 / month. Bandwidth between S3 and your Ec2 instance costs nothing so is very attractive for Media Transcoding and other such tasks. The requirements were as follows: .NET 3.5 SP1 ASP.NET MVC Beta SQL Server Express 2008 with Advanced Services IIS 6.0 Velocity Ideally I would want to host the Application on a Windows Server 2008 instance so that I could leverage the features of IIS 7.0 and also have a dedicated SQL Server 2008 instance, but unfortunately Amazon does not support this yet and it's unclear when this will happen so I had to use a makeshift approach. To manage your instances you can and should use th...

ASP.NET MVC Beta - HtmlHelper.TextBox change

I've just come across a minor change which caused the Value on my TextBox's to be set to "System.Collections.Generic.Dictionary`2[System.String,System.Object]" The HtmlHelper.TextBox method has changed. The previous (MVC Preview 5) method overloads were HtmlHelper.TextBox(string name) HtmlHelper.TextBox(string name, object htmlAttributes) HtmlHelper.TextBox(string name, string value) HtmlHelper.TextBox(string name, IDictionary htmlAttributes) HtmlHelper.TextBox(string name, string value, object htmlAttributes) HtmlHelper.TextBox(string name, string value, IDictionary htmlAttributes) These have been changed to: HtmlHelper.TextBox(string name) HtmlHelper.TextBox(string name, object value) HtmlHelper.TextBox(string name, object value, object htmlAttributes) HtmlHelper.TextBox(string name, object value, IDictionary htmlAttributes)

ASP.NET MVC Beta The type name System.Web.Mvc.IController, System.Web.Mvc could not be located

If you haven't heard by now the ASP.NET MVC Beta has been released and is available for download . NB: You will need to uninstall Preview 5 before trying to install. Big ups to the team for getting to this stage and the inclusion of jQuery is a very nice addition. Thanks to Derik for a heads up on some of the changes. There are far less breaking changes than previous releases which is great. If you're using a custom Controller Factory to inject the Controller at runtime you might come across this when you try and browse to a page. The type name System.Web.Mvc.IController, System.Web.Mvc could not be located Because they have added the System.Web.Mvc, System.Web.Routing & System.Web.Abstractions assemblies to the GAC they aren't copied to the Bin by default. So make sure you right click on System.Web.Mvc , go to Properties and set Copy Local to "true". Basic stuff I know but had me scratching my head for a second or two.