Skip to main content

Posts

Showing posts with the label ASP.NET MVC Learning

ASP.NET MVC Learning 4 : Session Handling

ViewData : Needs typecast, and has intellisense support, scope is only limited to that view, not across action methods ViewBag : scope is similar to ViewData, but it is dynamic, no typecasting needed, no intelisense is available TempData : Across actions   or views but only to the same controller, if it is used then the data will be last until the last usage Session :   Global scope, can be accessed anywhere

ASP.NET MVC Learning : Routing Advanced

To specify a route you need to create the instance of the class Route by specifying the  * URL Pattern Name  * URL Pattern   * Handler URL Name   Can be of any name and empty string '' is allowed URL Pattern  Default (System generating) URL pattern is {controller}/{action}/{id}, however you can use the following patterns as you want employee/{action}/{entry} --> employee/update/111 {reportname}/{year}/{month} --> employeeattendance/2018/06 {classcode}-{studentid}/{action} --> XII/212/show Handler There are three types of handlers used, MvcHandler, This handler is initiating the ASP.NET pipeline for the ASP.NET MVC application, as this is receiving the controller instance from MVC controller factory, which takes care of further processing  MvcRouteHandler  MvcRouteHandler is implementing the IRouteHandler interface and pass the request context to it. MvcHttpHandler Used to handle the mapping directly without going through the routing mod

ASP.NET MVC Learning 1 : Introduction

ASP.NET MVC is the open source web application building framework from Microsoft which implements (M-V-C) pattern,   M - Model  --> Contains Data and information on how to handle data (Business Logic) V - View --> Representation of data to the user (User Interface, Front End) C - Controller --> Sits between the Model and View, acts as interface between them, basically the controller takes the user request and provide the view with correct model data   This is software developing pattern which implements Seperation of Concerns (SoC), which decouples all the three components to enable it for better parallel programming, Advantages of MVC pattern Easy and Fast Development of code More meaningful URLs which provides the competetive edge over traditional URLs  Change Friendly Maintenance Friendly Test Friendly (Test Driven Development is fully supported) Easy to divide the application and respective teams such as Design Team, Developent Team, Database Team can co

ASP.NET MVC Learning 2 : Routing Basics

ASP.NET Routing in ASP.NET MVC  is the concept of mapping the incoming request (URL) with the existing resources  For Example :  The incoming request URL for a local application is http://localhost:2233/home/index In the Application say we have configured the routing as "{controller}/{action}/{id}", so Home is the controller here and index is the action here, the id is optional in most cases, if id is not given then it will display the default value In ASP.NET MVC the controllers should have the naming convention, in this case the controller's name should be Home Controller, should end with 'Controller' suffix. The Routing mechanism looks in the HomeController for the Action that we set already, Here Home is Controller and the Action is Index In the Home Controller we will return the View (That is Index) as Action Result Sample Home Controller public class HomeController : Controller { public ActionResult Index ( ) { return V