Skip to main content

Posts

Showing posts from May, 2020

Views in Asp.net Mvc

In this article we will learn about Views in ASP.NET MVC framework, Basically view is the user interface. View display data from model class to viewers. Create New View Open StudentController class then right click inside Index method and Click Add View. After Click Add View , Select "Empty(Without model) " from Add View dialog box then click OK. It will add Index View in View folder. This is how you can add views.

Model in Asp.net Mvc

In this article we will learn about Data Model in ASP.NET MVC. Models represents domain or business logic in MVC architecture. Model hold data in public properties. Adding a Model: Open our MVC project. Right click on model folder - > Add - > click on Class. In the Add New Item dialog box, enter class name "Employee and click Add button. This will add new Employee class in model folder, Now add some public properties like id,name,age,address. So this is the way you can create your model class. In the next article we will learn about View. Click here to learn about Views in ASP.NET MVC

Action Selector in Asp.net Mvc

Action Selectors Action selector are the attribute that applied to action method to handle a particular requests. MVC 5 have following action selector attributes: 1) ActionName 2) NonAction 3) ActionVerbs ActionName: It allow us to specify different ActionName then the method name. [ActionName("Student")] public ActionResult StudentName(string stuName) {      return View(); } In the above example, before specify [ActionName("Student")] , action method name was "StudentName" but after applying ActionName the new name of action method is "Student". NonAction: NonAction method indicates that the public method of a controller is not an action method. If you apply NonAction then it will not treat as a Method. [NonAction] public ActionResult StudentName(string stuName) {      return View(); } ActionVerbs: MVC framework support following ActionVerbs: 1) HttpGet ...

Action Method in Asp.net Mvc

In this article we will learn about Action Method. Basically it handles the incoming request and generate response. All the public method of a controller class are called Action Method with some restrictions: 1) Action method must be public. It cant be private or protected. 2) Action method cant be static. Types of Action Action returns multiples types of action like given below: FileContentResult Returns file content JavaScriptResult Returns script for execution JsonResult Returns JSON formatted data RedirectToResult Redirects to the specified URL ViewResult Received as a response for view engine PartialViewResult Received as a response for view engine You can use any of this to your controller to handle request and respond to it. In the next article we will learn about Action Selector. Click here to Learn about Action Selector

Controller in Asp.net Mvc

In this article we will know about Controller in ASP.NET MVC. The Controller handles incoming URL requests. It is a class which is derived from base class System.Web.Mvc.Controller. In MVC , every controller class name must end with word "Controller". Let say, controller for home page must be HomeController or contact controller must be ContactController. Creating an Empty ASP.NET MVC application Now adding a new controller in MVC application. In Visual Studio, right click on Controller folder - > select Add - > click on Controller. After that it will open Add Scaffold dialog as shown Select "MVC 5 Controller - Empty" and click add button after that it will open Add Controller dialog as shown In Add Controller Dialog add a name like you want to create student controller then just replace "Default" with "Student" as shown This will create "StudentController" as shown Exam...

ASP.NET MVC Folder and File Structure

When we create an ASP.NET MVC 5 application, the Visual Studio by default creates the following folders and files for our application. App_Data App_Data folder can contain application data files like LocalDB, .mdf files, xml files and other data related files. App_Start: The App_Start folder of an MVC application is used to contain the class files which are needed to be executed at the time of application starts. The classes like BundleConfig, FilterConfig, RouteConfig, IdentityConfig, etc are stored within this folder. So in the simple word we can say that configuration related class files are stored here.  We will discuss the use of each of these class files in detail in our upcoming articles. Content Content folder contain static files like css, images and icons and MVC 5 application includes bootstrap.min.css, bootstrap.css and site.css by default. Controller Controller folder contain class file. It handles user request and response....

Create First MVC App

In this article, I am going to discuss how to create the first  ASP.NET MVC Application   step by step from scratch using Visual Studio 2015. You can use any version as per your choice but the step will remain the same. Please read our previous article before proceeding to this article where we gave a brief introduction to ASP.NET MVC Framework. STEPS: Open Visual Studio 2017 and select  File menu  ->  New  ->  Project , as shown below   From New Project Dialog window select ASP.NET Web Application(.NET Framework) and application name as well as location as show in below: Then Select MVC and change authentication as show in below : To change authentication just click on 'Change Authention' then Change Authentication dialog box will open select 'No Authentication' radio button and select OK. Once you click OK button then it will take sometime to load project: Now press F5...

ASP.NET MVC - Get Started

ASP.NET is a free web framework for building websites and web applications on .NET Framework using HTML, CSS, and JavaScript. These tutorials are designed for beginners and professionals who want to learn ASP.NET MVC 5. In the next article we will learn How to Create First Asp.net MVC application. Click Here To Create First MVC Application