Reworking ASP.NET MVC Store with MVC# Framework
page 4 of 5
by Oleg Zhukov
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 27443/ 62

Starting the Application

Starting an MVC# application means just starting one of its tasks. In our case we will start the Main Task. The common place in ASP.NET programs for the initial task staring code is the session start handler (in Global.asax file).

Listing 19

<!---------------------- Global.asax file -------------------->
<script runat="server">
    ...
    public void Session_Start(object sender, EventArgs e)
    {
        TasksManager tm = new TasksManager(WebformsViewsManager.
                                               GetDefaultConfig());
        tm.StartTask(typeof(MainTask));
    }

As seen above, we are using a TasksManager instance to start the task. However, each tasks manager requires some configuration before using it. Above, we are passing a standard configuration object intended for Web applications to the tasks manager constructor.

The last thing left to do is to define mapping between views and corresponding web pages. For this we should add the following code to the Global.asax <script> block.

Listing 20

<!---------------------- Global.asax file -------------------->
<script runat="server">
    ...    
    [WebformsView(typeof(MainTask), MainTask.Welcome, "Default.aspx")]
    [WebformsView(typeof(MainTask), MainTask.ProductCategories,
                                            "ProductCategories.aspx")]
    [WebformsView(typeof(MainTask), MainTask.Products, "Products.aspx")]
    [WebformsView(typeof(MainTask), MainTask.EditProduct, "EditProduct.aspx")]
    class ViewDescriptions { }

That is all, we have successfully finished our example application and it is ready to run!


View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-25 4:02:59 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search