Upgrading to asp.net 4.0 & MVC 3

Time to get my hand dirty with some new web app.

I setup a new account on somee, that hosts asp.net 4 apps for free.

Uploaded a fresh new “hello world” app created by Visual studio 2010.

Wanting to make something with asp.net and MVC I configured the web app to also support MVC 3 following instruction foun here. Nothing fancy, only few steps to get things done.

To ease this process I created another web app configured as MVC 3 and compared the two.

So I added references to appropriate assembly (some assembly not found directly, but for System.Web.Mvc.dll under C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll).

Then modified web.config adding relevant tags.

Same thing for global.asax.cs, registering filters into the app.

Also modify the .csproj file and especially add proper ProjectTypeGuids i.e.

<ProjectTypeGuids>{E53F8FEA-EAE0-44A6-8774-FFD645390401};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>

To start quickly I followed the pluralsight training video as suggested by Scott Guthrie.

In the /Controllers dir there’s (guess what..) the controllers. Named with the name we choose terminating with a “Controller” string.

Views are stored under the /Views dir, grouped in a dir named as the controller.

So if we want to create a “Hello” controller the directory structure will be:

/Controllers/HelloControlles

/Views/Hello/Index.cshtml

HelloController.cs
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6.  
  7. namespace FitCalc.Controllers
  8. {
  9.     public class HelloController : Controller
  10.     {
  11.         //
  12.         // GET: /Hello/
  13.  
  14.         public ActionResult Index()
  15.         {
  16.             ViewBag.Message = "Welcome to ASP.NET MVC!";
  17.             return View();
  18.         }
  19.  
  20.     }
  21. }

.cshtml is the razor file implementing the view.

The URL for this view is /Hello/Index.

posted @ venerdì 18 febbraio 2011 00:25

Print
Comments have been closed on this topic.
«dicembre»
domlunmarmergiovensab
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234