Thursday, 17 October 2013

MVC4 Razor :Routing or Set StartUp page in ASP.NET MVC4 with example using C#.NET

Hi friends,in this article I will explain about MVC4 Razor Routing or Set StartUp page in MVC4 with example.
In Next articles I will explained about MVC4 Razor: How to use sessions using C#,MVC4 Razor:How to call Stored Procedure using C# and How to Create Cascading DropDownList in MVC 4 Razor and JQuery.

Open the Global.asax file

And comment the below lines
RouteConfig.RegisterRoutes(RouteTable.Routes);
And write the following code in code behind
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;

namespace MvcCRUD
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode,
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            //RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();
            CreateRouter(RouteTable.Routes);
        }
        public static void CreateRouter(RouteCollection routes)
        {
            routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // Route Pattern
            new { controller = "Account", action = "Register", id = UrlParameter.Optional } // Default values for above defined parameters
            );
        }

       
    }
}


When you Run the project then /Account/Register page will open automatically.
Incoming Processing By Routing system as shown in the below figure.

NEXT CHAPTER >>

"If you like my blog or articles, you can appreciate by leaving your comments or Liking my Facebook pageAspdotnet-kishore, following on Google+ Aspdotnet-Kishore, Twitter  on AspdotnetKishore, Linked in Aspdotnet-Kishore, stumbling my posts on stumble upon and subscribing on  RSSfeed Aspdotnet-Kishore for free updates directly to your Email inbox . Watch my blog  for more articles."

No comments:

Post a Comment

© 2012-2018 Aspdotnet-Kishore.blogspot.com. All Rights Reserved.
The content is copyrighted to Kishore and may not be reproduced on other websites without permission from the owner.