ASP dot net backend what i know in shorts:

We can create a controller, If we want to make a controller name as HelloWorld then we create a controller class by HelloWorldController and then we make it inherited from the controller class, then we can make a method to it using IActionResult to it and that will be a index method on our HelloWorld controller and we need to make a view HelloWorld for that as Index.cshtml, as this was the index method on our newly created HelloWorld controller. We use the ViewData for this. Its is a dictionary. 

We can give instruction to the controller to give output but it is a good practice to make separate view for that output and make a view for that and also view will only be responsible for the output not for any of the business logic.

Data passing from controller to view:

We define the ViewData inside the controller and then we pass some information as a object and also that can be of any data type. Simply return the view(). That will be going directly to the view of the project from the controller that we had created which was a inherited class or derived class from the main controller class.

We create a view in the newly added view of HelloWorld view, there we add a class named Welcome.cshtml.

ViewData: it is an dictionary, a dynamic object that means any type of data can be there.

Working with model, we create a model class named Movie.cs and then we import the things for data annotations, the namespace is [project name].Models, then we start typing EF code and that is exactly the thing we can do with SQL.

Nullable: there are two types in c# value types: bool, int they cant be null, means not nullable, they will hold a value must. other is reference types: delegates, class, arays they can be nullable.

Ex: int a? =null; //this is valid but, int b =null; //this is not valid as int can not hold null value as it is a value type it must hold any value inside of it.

Comments

Popular posts from this blog

c# .net learning From 19 Sep 2023

template

settings.json