Key Notes To ASP.NET MVC
ASP.NET MVC is open-source software. The ASP.NET MVC is a web application framework developed by Microsoft, which implements the model–view–controller pattern. Asp.Net MVC has Partial Views for code re-usability. In Asp.Net MVC, Views and logic are kept separately. Asp.Net MVC follows customizable syntax (Razor as default).Asp.Net MVC has html helpers.Asp.Net MVC is lightweight and follows MVC (Model, View, Controller) pattern based development model. Asp.Net MVC does not support view state.
Key Notes To Asp.Net Web Form
Asp.Net Web Form is not Open Source.Asp.Net Web Form follows a traditional event-driven development model.Asp.Net Web Form has server controls.Asp.Net Web Form supports view state for state management at client side.Asp.Net Web Form follows Web Forms Syntax.In Asp.Net Web Form, Web Forms(ASPX) i.e. views are tightly coupled to Code behind(ASPX.CS) i.e. logic. Asp.Net Web Form has User Controls for code re-usability.
Url Path Note Of ASP.NET MVC
Asp.Net MVC has route-based URLs which means URLs are divided into controllers and actions and moreover it is based on controller not on physical files.
Url Path Note Of ASP.NET Web Form
Asp.Net Web Form has file-based URLs means file name exist in the URLs must have its physical existence.
Description
Here I built one Asp.net MVC and Asp.net web form application.That will show you what the URL Path Concept Between ASP.NET MVC and ASP.NET Web Forms.
Link To Source Code
Steps to be followed For Asp.Net MVC
Step 1
Create a Mvc Project named "MvcWeb".
Step 2
Create class file in Models Folder named "Student.cs".
Code Ref
Step 1
Create a Mvc Project named "MvcWeb".
Step 2
Create class file in Models Folder named "Student.cs".
Code Ref
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.ComponentModel.DataAnnotations;
- namespace MvcWeb.Models
- {
- public class Student
- {
- [Display(Name = "Name")]
- public string StudentName { get; set; }
- }
- }
Add one variable or entity named "StudentName". To display the result in the page associate with label htmlhelper.
- public string StudentName { get; set; }
- [Display(Name = "Name")]
Step 3
Create a controller class file named "HomeController.cs".
Code Ref
Create a controller class file named "HomeController.cs".
Code Ref
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using MvcWeb.Models;
- namespace MvcWeb.Controllers
- {
- public class HomeController : Controller
- {
- //
- // GET: /Home/
- public ActionResult Satyaweb()
- {
- return View();
- }
- }
- }
Here I created one controller action method named "Satyaweb()". Add the namespace reference on Model class that is,
- using MvcWeb.Models;
Step 4
Create one view named "Satyaweb.cshtml" in Views/Home Folder as the same name in controller action method.
Code Ref
Create one view named "Satyaweb.cshtml" in Views/Home Folder as the same name in controller action method.
Code Ref
- @model MvcWeb.Models.Student
- @{
- ViewBag.Title = "Satyaprakash";
- }
- <h2 style="background-color: Yellow; color: Blue; text-align: center; font-style: oblique">
- Satyaprakash's Mvc Path Concept</h2>
- <fieldset>
- <legend style="font-family: Arial Black; color: blue">Student Name</legend>
- @Html.LabelFor(m => m.StudentName, "Satyaprakash Samantaray")
- </fieldset>
- <footer>
- <p style="background-color: Yellow; font-weight: bold; color:blue; text-align: center; font-style: oblique">© @DateTime.Now.ToLocalTime()</p> @*Add Date Time*@
- </footer>
Here I added namespace in view to access properties of student model class file.
- @model MvcWeb.Models.Student





mohamed ashrafPosted May 30, 2019, 3:15 AM
ThankS You
Zeeshan AzimPosted Nov 12, 2017, 2:36 AM
Great job Satya. Can you please write article over Partial views in mvc and how to reuse partial view in MVC.