Tag Archives: ASP.NET MVC

ASP.NET MVC RC on Mosso

Today, I setup my first production ASP.NET MVC website. After a little investigation and a contact to Mosso’s tech support everything went up as planned. The first step is to configure your application like you would for any IIS7 host. You don’t need to have the “mvc” extension after your controllers in your routes. Next upload the application to your Mosso website. When you upload your site make sure you include the ASP.NET MVC dll files in your website’s bin directory. The needed files are System.Web.Abstractions.dll, System.Web.Mvc.dll, and System.Web.Routing.dll. These files will be located in Program Files\Microsoft ASP.NET\ASP.NET MVC RC\Assemblies on your computer. At this point your default route should be working. The last thing to take care of is resolving the 404 error you will receive when accessing urls within the site.

image

The reason for the error is that Mosso runs all IIS7 applications in classic mode by default. You will need to contact Mosso tech support and ask them to switch your application to integrated mode. It will take about 15 minutes for the changes to propagate to all of Mosso’s servers. After the propagation is complete your ASP.NET MVC site should be up and running.

This process should work on any shared host or cloud host as long as they are running Windows Server 2008 and allow you to run your application in integrated mode.

ASP.NET 3.5 Extensions CTP Released

I downloaded and tested the new ASP.NET 3.5 Extensions today. There are many new and exciting features in the CTP. My favorite is the MVC (Model View Controller) Framework and its accompanying tools. The MVC framework is a complete 360 from traditional ASP.NET forms pages in a number of ways. First, there is a very clear separation of the layers of your ASP.NET web app. Second, you will notice the HTML output of a MVC app is extremely clean. There are not viewstate or other hidden tags among other things. Third, and probably most important, is the page life cycle is very different. While ASP.NET MVC is built on top of System.Web many events from the old System.Web.UI.Page class are not fired inside the new ViewPage class.

From a application development standpoint I think this new framework will help developers and designers work better together. I don’t have to worry much about what goes into the .aspx page and the the designer doesn’t have to worry about dependencies in my code. ("Is it okay to change this datalist to a repeater?") As a developer I am only responsible for passing objects into ViewData. The designer can insert these values wherever they please. For example, lets say I make a simple have a PersonController with the action Person. This action accepts an id value. So the url might be http://www.example.com/People/Person/32. Using my DataContext from my SQL to LINQ I use dc.GetPerson(id) to retreive a single person. From there I simply use RenderView(string viewName, object viewData) to render the view and pass the person object to ViewData. The Person object will be automatically placed into the ViewData dictionary and be accessible on the view using ViewData["FirstName"] for example.

 
The controller.

 image_2
The view.

image_4

The end result is a very maintainable piece of software, a very nice URL for the end user and clean HTML output. It will be interesting to see how this project progresses and how it fits into our software at Atlas Bay.