Add a Main Web Page to the Application
[This content is no longer valid. For the latest information on "M", "Quadrant", SQL Server Modeling Services, and the Repository, see the Model Citizen blog.]
This is the fifth step in the Getting Started with SQL Server Modeling CTP and Visual Studio 2010 tutorial. The preceding step is Develop Using Generated Entity Framework Classes. The following step is Generate "M" from an Existing Database. In this topic you will build a main Web page for the application that shows the upcoming dinners. The FindUpcomingDinners
method that you defined previously generates the rows that you will display in the Web page.
Build the main view for DinnersController
In the
DinnersController
class, right click theIndex
method and select Add View.In the Add View dialog box, select Create a strongly-typed view, select
MiniNerdDinner.Dinner
in the View data class box, and then select List in the View content box. Click Add.In the
DinnersController
class, modify theIndex
method to contain the following code. This connects theIndex
controller action to the strongly-typed view that you just created.public ActionResult Index() { var dinners = FindUpcomingDinners(); return View("Index", dinners); }
In Solution Explorer, double-click
Global.asax
and modify theRegisterRoutes
method to contain the following code. Note the change to the last argument toMapRoute
, which makes our new controller the default for the application.public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Dinners", action = "Index", id = "" } // Parameter defaults ); }
Run the application
In Solution Explorer, right-click
MiniNerdDinner.Tests
and select Set as Startup Project.Press F5 to start the application. The ASP.NET Development Server icon appears in the system tray.
Tip
The precise port portion of the URL may be different on your computer.
Right-click the icon and select Open in Web Browser.
A browser window appears. The main page should look as follows. Note that the Web page shows the instance data that you authored by using “M”.
Tip
The precise port portion of the URL may be different on your computer.
See Also
Concepts
Getting Started with SQL Server Modeling CTP and Visual Studio 2010