Click here to Skip to main content
15,897,371 members
Articles / Web Development / ASP.NET

"How to series" about MVC, jQuery, JSON, paging, mapRoute

Rate me:
Please Sign up or sign in to vote.
4.91/5 (86 votes)
19 Apr 2013CPOL12 min read 135.6K   4.8K   199  
"How to series" about MVC, jQuery, JSON, paging, mapRoute.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

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

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }

        public static void RegisterRoutes(RouteCollection routes)
        {

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");


            //--------------
            routes.MapRoute(
                "AddressSave",
                "Address/Save/{addressNo}/{personNo}",
                new { controller = "Address", action = "Save", 
                     addressNo = UrlParameter.Optional, personNo = UrlParameter.Optional }
            );
            //--------------


            //--------------
            routes.MapRoute(
                "AddressList",
                "Address/Index/{personNo}",
                new { controller = "Address", action = "Index", personNo = UrlParameter.Optional }
            );
            //--------------



            //--------------
            routes.MapRoute(
                "AddressDelete",
                "Address/DeleteAddress/{addressNo}",
                new { controller = "Address", action = "DeleteAddress", addressNo = UrlParameter.Optional }
            );
            //--------------

            //--------------
            routes.MapRoute(
                "PersonSave", // Route name
                "Person/Save/{personNo}", // URL with parameters
                new { controller = "Person", action = "Save", personNo = UrlParameter.Optional } // Parameter defaults
            );
            //--------------


            //--------------
            routes.MapRoute(
                "PersonDelete", // Route name
                "Person/DeletePerson/{personNo}", // URL with parameters
                new { controller = "Person", action = "DeletePerson", personNo = UrlParameter.Optional } // Parameter defaults
            );
            //--------------


            //--------------
            routes.MapRoute(
                "PersonPicSave", // Route name
                "Person/SavePersonPic/{personNo}", // URL with parameters
                new { controller = "Person", action = "SavePersonPic", personNo = UrlParameter.Optional } // Parameter defaults
            );
            //--------------



            //--------------
            routes.MapRoute(
                "NoteList", // Route name
                "Note/Index/{personNo}", // URL with parameters
                new { controller = "Note", action = "Index", personNo = UrlParameter.Optional } // Parameter defaults
                
            );
            //--------------


            //--------------
            routes.MapRoute(
                "NoteSave",
                "Note/Save/{noteNo}/{personNo}",
                new
                {
                    controller = "Note",
                    action = "Save",
                    addressNo = UrlParameter.Optional,
                    personNo = UrlParameter.Optional
                }
            );
            //--------------


            //--------------
            routes.MapRoute(
                "NoteDelete", // Route name
                "Note/DeleteNote/{noteNo}", // URL with parameters
                new { controller = "Note", action = "DeleteNote", noteNo = UrlParameter.Optional } // Parameter defaults

            );
            //--------------





            //--------------
            routes.MapRoute(
                "CountrySave", // Route name
                "Country/CountrySave/{countryNo}", // URL with parameters
                new { controller = "Country", action = "CountrySave", countryNo = UrlParameter.Optional } // Parameter defaults
            );
            //--------------


            //--------------
            routes.MapRoute(
                "ConuntryDelete", // Route name
                "Country/DeleteCountry/{countryNo}", // URL with parameters
                new { controller = "Country", action = "DeleteCountry", countryNo = UrlParameter.Optional } // Parameter defaults

            );
            //--------------



            

            //--------------
            routes.MapRoute(
                "Country",
                "County/CitySave/{countryNo}/{cityNo}",
                new
                {
                    controller = "Country",
                    action = "CitySave",
                    countryNo = UrlParameter.Optional,
                    cityNo = UrlParameter.Optional
                }
            );
            //--------------

            //--------------
            routes.MapRoute(
                "CityDelete", // Route name
                "Country/DeleteCity/{cityNo}", // URL with parameters
                new { controller = "Country", action = "DeleteCity", cityNo = UrlParameter.Optional } // Parameter defaults

            );
            //--------------








            //--------------
            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );
            //--------------

        


        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) NEBULACT
United Kingdom United Kingdom
Necmettin Demir is developer at NEBULACT Ltd. in London/UK.
He has BSc and MSc degrees of Computer Science. He was also graduated from MBA.
He is also trying to share his technical experience writing articles.

Comments and Discussions