ASP NET Core Model Binding

preview_player
Показать описание
In this video we will discuss Model Binding in ASP.NET Core with examples.

Healthy diet is very important for both body and mind. We want to inspire you to cook and eat healthy. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking.

Model binding maps data in an HTTP request to controller action method parameters

The action parameters may be simple types such as integers, strings, etc or complex types like Customer, Employee, Order etc.

Text version of the video

Slides

ASP.NET Core Text Articles & Slides

ASP.NET Core Tutorial

Angular, JavaScript, jQuery, Dot Net & SQL Playlists
Рекомендации по теме
Комментарии
Автор

I love when you say: "red squiggly"

MosquitoMurderer
Автор

Great! I'm from Brazil (we wrotes Brasil), and yours tutorials was help me learn more times that I'can remember! Thank you!

robsonsilva
Автор

You are the best tutor I've ever seen.

huseynmikayil
Автор

Thank you Venkat sir, you are awesome!

vinayakh
Автор

Excellent sir, Thanks a lot for Detail explanation....

jvusa
Автор

How does the repository store information? Because we used AddSingleton for the Employee repository service. AddSingleton maintains state. If we hadn't, without the use of a database, session variable, etc. the new employee added would have been immediately lost upon clicking create.

roadtripping
Автор

Sir, your videos are always great and I have never seen a tutor like you. You are really great. And I love the music gets played end of the every videos of this series simply nice and soothing.

saranyasaran
Автор

Sir. Thank you very much for in detailed explanation.
I have a doubt here,
how is it even able to remember the created data between states in the current tutorial, When I navigate to Index method it still retains the new created data and the same is retained in every state.as we have learnt that its stateless.

dheemanthanand
Автор

question, when you are creating view is that where you bind model or it can automatically understand when controller takes "Student" as parameter to assign model to it . is not view responsible to model binding?

grandmagus
Автор

I'm confused one thing that why in the controller we perform everything in the interface but not in the actual object? we have IEmployeeRepository is an interface and MockEmployeeRepository is an object class that implements that interface. Why we don't instantiate the object in the controller but just the interface? New to C# sorry

HungVo-fpxk
Автор

In my case the ViewModel object has all its attributes with null value, not a single value I entered shows on it

reneh
Автор

I received NullReferenceException because I had AddTransient method in startup.cs instead of AddSingleton. After I changed it the create button started working well, hope it will help someone

oleksandr
Автор

Are there benefits to save it to an separated newEmployee object instead of below code?



return RedirectToAction("details", new { id = employee.Id });

kennethcheung
Автор

can anybody explain why do I need to change add transient to singleton?

aarbiayaz
Автор

I need some suggestions. I have been following along learning a lot. This is the first time I have gotten stumped.


My Create Post action does not seem to be getting to the HomeController Post method. There are no build errors. Output shows a lot of threads exiting with error code 0.
I have tried putting Break points on both the Get and Post HomeController methods. The HttpGet Create method is being hit, the HttpPost Create method is not.


How can I further debug this?


Thank you very much. BTW I am using VS 2019 Core 2.2

mp-otfw
Автор

How the heck is .net core doing that? Where does the info submited in the form gets stored? In memory? For how long?

CrivatFlorin
Автор

Hi Venkat, Department value (drop down value ) is going null with httppost. Could you please help.

pranavsinha
Автор

Hi Venkat, What is the lifetime of the _employeeList object after creating and adding new Employee object to it?

giokavlashvili
Автор

Thank you for tutorial. While practicing the session I came across an issue, Parameter ID never receives value, it is holding null value even though Create method has all required details. below is code snippet:
public employeeRepository)
{
_employeeRepository = employeeRepository;
}

[HttpPost]
public RedirectToActionResult Create(Employee employee)
{
Employee newEmployee =
return RedirectToAction("Details", new { id = newEmployee.Id });
}



public ViewResult Details(int? empId)
{
HomeDetailsViewBased homeDetailsViewBased = new HomeDetailsViewBased();
homeDetailsViewBased.Employee = ?? 1);
= "Employee Details";
return View(homeDetailsViewBased);
}
Any guidance how to overcome empId receiving null will be helpful using .net core 3.1

anuyajoshi
Автор

NullReferenceException: Object reference not set to an instance of an object.
in Details.cshtml
+


sir help me to clear this error

jazicasri