Skip to content

AlexChorvadi/SampleMVCCoreApp

Repository files navigation

Understanding MVC Core Concept as Beginner

  • _Layout.cshtml :-
    • Contain in Shared Folder. This File is Same Like Master Page in WebForms
  • Controller.cs :-
    • Calling Any Function With IActionResult Method.
    • For Example - _Layout.cshtml Code Snippet -> <a asp-controller="Home" asp-action="Foo"> Foo Text </a>
      HomeController.cs Code Snippet -> public IActionResult Foo() { return View(); } This Defining That We Use Foo Method of HomeController
  • Model :-
    • Add New Model File With Visual Studio -> Right-click the Models folder > Click Add > Click Class > Name the file ModelName.cs
    • Same as Prop We Made in WebForms. We Can Use Model Directly in View Page With Help of Razor Page Using @ModelName
  • Add Model In View Page ViewPageName.cshtml
    • Top of the Page Add @model ModelName
    • For Storing Value in Model We Use asp-for attribute in Element
      For Example : <input type="text" asp-for="FirstName" id="FirstName">
    • asp-for Only Works When we add Model into our View page as per First Point

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors