No video

ASP NET Core Model Binding

  Рет қаралды 147,110

kudvenkat

kudvenkat

Күн бұрын

Пікірлер: 106
@MosquitoMurderer
@MosquitoMurderer 5 жыл бұрын
I love when you say: "red squiggly"
@robsonsilva9490
@robsonsilva9490 2 жыл бұрын
Great! I'm from Brazil (we wrotes Brasil), and yours tutorials was help me learn more times that I'can remember! Thank you!
@huseynmikayil5119
@huseynmikayil5119 5 жыл бұрын
You are the best tutor I've ever seen.
@saranyasaran1916
@saranyasaran1916 4 жыл бұрын
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.
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 4 жыл бұрын
Hello Saranya - Thank you very much for the feedback. Means a lot. I have included all the .NET core tutorial videos, slides and text articles in sequence on the following page. Hope you will find it handy. www.pragimtech.com/courses/asp-net-core-mvc-tutorial-for-beginners/ When you have some time, can you please leave your rating and valuable feedback on the REVIEWS tab. It really helps us. Thank you. Good luck and all the very best with everything you are doing.
@chessgamesonline5867
@chessgamesonline5867 2 жыл бұрын
its confusing.
@roadtripping
@roadtripping Жыл бұрын
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.
@yasirirfan5262
@yasirirfan5262 3 ай бұрын
brilliant explanation.
@oleksandr8923
@oleksandr8923 5 жыл бұрын
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
@pavitersingh3451
@pavitersingh3451 2 жыл бұрын
Thanks bro
@jvusa
@jvusa 3 жыл бұрын
Excellent sir, Thanks a lot for Detail explanation....
@dheemanthanand731
@dheemanthanand731 4 жыл бұрын
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.
@mertkurt947
@mertkurt947 Жыл бұрын
you are awesome teacher , thank you
@reneh5
@reneh5 4 жыл бұрын
In my case the ViewModel object has all its attributes with null value, not a single value I entered shows on it
@yashaswikeote7689
@yashaswikeote7689 5 жыл бұрын
Please make video on azure DevOps
@turhansaltas9284
@turhansaltas9284 4 жыл бұрын
you are the king brother.
@RicardoJnfrazao
@RicardoJnfrazao 3 жыл бұрын
Great tutorial.
@AbuSayed-gf8gt
@AbuSayed-gf8gt 3 жыл бұрын
Great tutorial !
@vinayakh7730
@vinayakh7730 5 жыл бұрын
Thank you Venkat sir, you are awesome!
@grandmagus8618
@grandmagus8618 2 жыл бұрын
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?
@HungVo-fp7xk
@HungVo-fp7xk 4 жыл бұрын
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
@AbdullahTaherAbubakar
@AbdullahTaherAbubakar 4 жыл бұрын
Great Lesson As Always... One Question Though : Every time you add a new employee (object) to the list; the list gets updated even after you do the redirect. The question is where is the list get stored?..is it cached or what? #kudvenkat
@javaguitarist
@javaguitarist 4 жыл бұрын
It probably has to be just in memory. When he gets into the database model, you will see how it is inserted into the database where you can see it. If you close the solution and reopen it, new users do not persist.
@apositron84
@apositron84 4 жыл бұрын
Yes! I was confused about that as well. Voodoo!
@peritusdemi5028
@peritusdemi5028 4 жыл бұрын
In your " Startup.cs " class you have added a service "services.AddSingleton();" This AddSingleton is responsible for caching your data in your browser. If you delete the cache, your added data will also be removed.
@AbdullahTaherAbubakar
@AbdullahTaherAbubakar 4 жыл бұрын
@@peritusdemi5028 Thank you for making it even clearer.
@anuyajoshi4360
@anuyajoshi4360 4 жыл бұрын
@@peritusdemi5028 - Thank you for sharing this information.
@kennethcheung4911
@kennethcheung4911 4 жыл бұрын
Are there benefits to save it to an separated newEmployee object instead of below code? _employeeRepository.Add(location); return RedirectToAction("details", new { id = employee.Id });
@naodagere8210
@naodagere8210 4 жыл бұрын
Thank you very much.
@eugene-white-shark
@eugene-white-shark 2 жыл бұрын
Thank you!
@marcol5374
@marcol5374 4 жыл бұрын
Hello Master, please explain me when exactly the new object as a parameter to Create(Employee employee) has been created? In the Create.cshtml file we map the property to an object of a Class Employee but i can't see the new object. Thanks a lot
@marcol5374
@marcol5374 4 жыл бұрын
Automatically created by Model Binding !
@peritusdemi5028
@peritusdemi5028 4 жыл бұрын
Run the Create(Employee employee) method in debug mode, and follow your code line by line. You will understand how the object have been created.
@marcol5374
@marcol5374 4 жыл бұрын
@@peritusdemi5028 of course but in the code there isnt any new keyword. The object is automatically created by model Binding and passed to the Create method
@sakthir3892
@sakthir3892 5 жыл бұрын
Sir, nice explanation
@mp-ot7fw
@mp-ot7fw 5 жыл бұрын
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-ot7fw
@mp-ot7fw 5 жыл бұрын
Nevermind, it was my html. I changed the button for an input type="submit". Works great! TYVM for these tutorials!
@user-kr9gm6pi6w
@user-kr9gm6pi6w 5 жыл бұрын
How to fix the error:NullReferenceException. I already use AddSingleton.But Constructor I use with _employeeRepository = new MockEmployeeRepository();
@harag9
@harag9 5 жыл бұрын
Check you have the below code in the Startup.cs file in the method "ConfigureServices" -- services.AddSingleton();
@mdsaddamkhan8400
@mdsaddamkhan8400 4 жыл бұрын
I have the same code but can't help it.
@saidamir4268
@saidamir4268 3 жыл бұрын
Thank you.
@christianloperadecastro4875
@christianloperadecastro4875 5 жыл бұрын
An unhandled exception occurred while processing the request. NullReferenceException: Object reference not set to an instance of an object. NullReferenceException: Object reference not set to an instance of an object. AspNetCore.Views_Home_Details.ExecuteAsync() in Details.cshtml + @Model.Employee.Name //I receive this error message. Can you show some solution for this.Thanks you
@hossammetwally07
@hossammetwally07 5 жыл бұрын
did you get the explanation?
@lukedodson3441
@lukedodson3441 5 жыл бұрын
Home controller constructor needs to be changed
@crimcrow
@crimcrow 4 жыл бұрын
Same issue for me
@codeautomate8155
@codeautomate8155 5 жыл бұрын
null reference exception is occured when press create button how can i solve it?
@lukedodson3441
@lukedodson3441 5 жыл бұрын
Same thing happened here
@lukedodson3441
@lukedodson3441 5 жыл бұрын
Change the HomeController constructor
@anuyajoshi4360
@anuyajoshi4360 4 жыл бұрын
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 HomeController(IEmployeeRepository employeeRepository) { _employeeRepository = employeeRepository; } [HttpPost] public RedirectToActionResult Create(Employee employee) { Employee newEmployee = _employeeRepository.Add(employee); return RedirectToAction("Details", new { id = newEmployee.Id }); } [Route("[Controller]/[action]/{id?}")] public ViewResult Details(int? empId) { HomeDetailsViewBased homeDetailsViewBased = new HomeDetailsViewBased(); homeDetailsViewBased.Employee = _employeeRepository.GetEmployee(empId ?? 1); homeDetailsViewBased.PageTitle = "Employee Details"; return View(homeDetailsViewBased); } Any guidance how to overcome empId receiving null will be helpful using .net core 3.1
@conaxlearn8566
@conaxlearn8566 3 жыл бұрын
In the Route you have {Id?}, but in the method parameter you called it 'empId' instead of 'Id'.
@giokavlashvili7003
@giokavlashvili7003 5 жыл бұрын
Hi Venkat, What is the lifetime of the _employeeList object after creating and adding new Employee object to it?
@lukedodson3441
@lukedodson3441 5 жыл бұрын
Think it's just until the app is closed since its only a mock repository.
@cesareemauritanie5288
@cesareemauritanie5288 4 жыл бұрын
Top Thank you !!!
@ravichandragangavarapu1259
@ravichandragangavarapu1259 2 жыл бұрын
Sir u said everything about mvc by using asp dot net core
@coolwaterdvr
@coolwaterdvr 5 жыл бұрын
Thanks Venkat.
@pranavsinha9821
@pranavsinha9821 4 жыл бұрын
Hi Venkat ,Department value (drop down value ) is going null with httppost. Could you please help.
@peritusdemi5028
@peritusdemi5028 4 жыл бұрын
Try to debug your code and monitor the error.
@RachitJain4U
@RachitJain4U 3 жыл бұрын
Thanks Sir :)
@CrivatFlorin
@CrivatFlorin 3 жыл бұрын
How the heck is .net core doing that? Where does the info submited in the form gets stored? In memory? For how long?
@preetijuyal1742
@preetijuyal1742 5 жыл бұрын
hi @KudVenkat sir, it would be very helpful if a concept is explained with respect to previously used concepts and techniques in place of this concept and technique to achieve a particular functionality and how this concept is implemented in various languages.
@heemelhimaddri534
@heemelhimaddri534 5 жыл бұрын
Sir, actually I want to learn asp.net but I can't take any decisions till now because of some hesitations. should I need to start with asp.net or asp.net core ?
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 5 жыл бұрын
Hello Wag - ASP .NET Core is a new technology from Microsoft. However, there are still plenty of opportunities with ASP .NET MVC. Lot of ASP .NET MVC concepts are also relevant in ASP .NET Core. So I suggest learn both ASP .NET MVC and ASP .NET Core to expand your skill set. Hope this helps.
@sanjuds1
@sanjuds1 4 жыл бұрын
@@Csharp-video-tutorialsBlogspot Hello Sir , whether model binding in asp.net mvc same as asp.net core model binding.
@sunnysharma5635
@sunnysharma5635 2 жыл бұрын
Make one tutorial for web api using asp. Net core
@codeautomate8155
@codeautomate8155 5 жыл бұрын
thank you
@salmanchowdarym1110
@salmanchowdarym1110 4 жыл бұрын
Thanks
@aarbiayaz4744
@aarbiayaz4744 4 жыл бұрын
can anybody explain why do I need to change add transient to singleton?
@pablosalas8586
@pablosalas8586 4 жыл бұрын
Can someone explain to me why it created a new employee without using the instance or the keyword "new", just added it? thx
@peritusdemi5028
@peritusdemi5028 4 жыл бұрын
This is created in your MockEmployeeRepository class with it constructor.
@mohammadhilal8508
@mohammadhilal8508 4 жыл бұрын
sir, when i add employee and next time when i restart the application it does not show me the added employee. what would be the reason pls help me.And it also does not add employee to my list.
@navinbadlani9211
@navinbadlani9211 4 жыл бұрын
When we are restarting our application MockEmployeeRepository constructor is getting called and list is reset to that 3 items which we are adding inside constructor and once application starts so we can add more items through create option but that newly created items will be there till the application is running once we restart it will again come back to original list
@mohammadhilal8508
@mohammadhilal8508 4 жыл бұрын
@@navinbadlani9211 okay, I got it and thanks for the reply. So what we can do to overcome it.
@naodagere8210
@naodagere8210 4 жыл бұрын
@@mohammadhilal8508 We will use SQL database and I hope he will cover that part in the coming slides
@peritusdemi5028
@peritusdemi5028 4 жыл бұрын
Use this in your constructor: public HomeController(IEmployeeRepository employeeRepository) { _employeeRepository = employeeRepository; }
@jazicasri9248
@jazicasri9248 4 жыл бұрын
NullReferenceException: Object reference not set to an instance of an object. AspNetCore.Views_Home_Details.ExecuteAsync() in Details.cshtml + Name:@Model.Employee.Name sir help me to clear this error
@lukedodson3441
@lukedodson3441 5 жыл бұрын
@Model.Employee.Name is null apparently. The Add function doesn't seem to be working for me
@MukundPatel
@MukundPatel 5 жыл бұрын
did you get reason and solution? I am facing the same issue. so please share with me.
@lukedodson3441
@lukedodson3441 5 жыл бұрын
@@MukundPatel home controller constructor needs changing
@lukedodson3441
@lukedodson3441 5 жыл бұрын
@@MukundPatel you get it working?
@peritusdemi5028
@peritusdemi5028 4 жыл бұрын
The constructor of the MockEmployeeRepository class already has a new employee list object. So you don't need a new MockEmployeeRepository in HomeController constructor. So use this in your HomeController constructor instead: public HomeController(IEmployeeRepository employeeRepository) { _employeeRepository = employeeRepository; }
@mdsaddamkhan8400
@mdsaddamkhan8400 4 жыл бұрын
@@peritusdemi5028 I did the same thing but it could not help
@hossammetwally07
@hossammetwally07 5 жыл бұрын
NullReferenceException: Object reference not set to an instance of an object. AspNetCore.Views_Home_Details.ExecuteAsync() in Details.cshtml
@lukedodson3441
@lukedodson3441 5 жыл бұрын
Change the HomeController constructor
@edmond1314
@edmond1314 3 жыл бұрын
@@lukedodson3441 Inconsistent accessibility: parameter type 'IEmployeeRepository' is less accessible than method 'HomeController.HomeController(ILogger, IEmployeeRepository)
@lukedodson3441
@lukedodson3441 5 жыл бұрын
Got a null reference exception
@Pasaaydaan
@Pasaaydaan 3 жыл бұрын
I am also getting null reference exception
@lukedodson3441
@lukedodson3441 3 жыл бұрын
@@Pasaaydaan change the Home Controller constructor
@ShivamSingh-oe8tz
@ShivamSingh-oe8tz 4 жыл бұрын
I'm getting redirected to "create/home" instead of" home/details/id" can anyone tell why!
@ypwygk652
@ypwygk652 3 жыл бұрын
i have the same prolem
@debarghyachakraborty
@debarghyachakraborty 3 жыл бұрын
Try correcting the RedirectToAction method.
@chessgamesonline5867
@chessgamesonline5867 2 жыл бұрын
A bit confusing. :)
@lukedodson3441
@lukedodson3441 5 жыл бұрын
Fixed it haha
@lukedodson3441
@lukedodson3441 5 жыл бұрын
@Marc Daniel P. Zornosa what you mean?
@user-kr9gm6pi6w
@user-kr9gm6pi6w 5 жыл бұрын
Who have error. public HomeController(IEmployeeRepository employeeRepository) { _employeeRepository = employeeRepository; }
@harag9
@harag9 5 жыл бұрын
You shouldn't be getting at this point if you had been following all 40 videos, no change here in this video - It would also help if you actually said what error you're getting.
@naodagere8210
@naodagere8210 4 жыл бұрын
Thanks. This has solved the NullReferenceException error
@peritusdemi5028
@peritusdemi5028 4 жыл бұрын
Thanks, from this video, your proposed method is working. solving the NullReferenceException error
@mdsaddamkhan8400
@mdsaddamkhan8400 4 жыл бұрын
I have
@himanshudashore3866
@himanshudashore3866 2 жыл бұрын
I got this error NullReferenceException: Object reference not set to an instance of an object. AspNetCore.Views_Home_Details.ExecuteAsync() in Details.cshtml, line 9 Line no. 9 code is : @Model.Employee.Name
@matanfadida15
@matanfadida15 Жыл бұрын
you find solution?
@Dubeysaurabh592
@Dubeysaurabh592 Жыл бұрын
got any solution for this ?
ASP NET Core model validation
10:19
kudvenkat
Рет қаралды 112 М.
AddSingleton vs AddScoped vs AddTransient
15:23
kudvenkat
Рет қаралды 211 М.
Survive 100 Days In Nuclear Bunker, Win $500,000
32:21
MrBeast
Рет қаралды 165 МЛН
طردت النملة من المنزل😡 ماذا فعل؟🥲
00:25
Cool Tool SHORTS Arabic
Рет қаралды 18 МЛН
КТО ЛЮБИТ ГРИБЫ?? #shorts
00:24
Паша Осадчий
Рет қаралды 3,1 МЛН
OMG what happened??😳 filaretiki family✨ #social
01:00
Filaretiki
Рет қаралды 13 МЛН
Repository pattern in asp net core
14:50
kudvenkat
Рет қаралды 302 М.
(#14) Model in Asp.Net core | Asp.Net Core tutorial
20:19
WebGentle
Рет қаралды 34 М.
Form tag helpers in asp net core
11:12
kudvenkat
Рет қаралды 109 М.
THIS is how you use Partial Views in ASP.NET Core 6
10:06
tutorialsEU - C#
Рет қаралды 32 М.
Forget Controllers and Minimal APIs in .NET!
14:07
Nick Chapsas
Рет қаралды 65 М.
Top 100  C#/ .NET/ Web API/ SQL Interview Questions
2:49:20
Interview Happy
Рет қаралды 537 М.
What is Dependency Injection in .NET?
7:31
DotNetMastery
Рет қаралды 23 М.
Introduction to ASP.NET Core MVC in C# plus LOTS of Tips
1:03:56
IAmTimCorey
Рет қаралды 331 М.
Survive 100 Days In Nuclear Bunker, Win $500,000
32:21
MrBeast
Рет қаралды 165 МЛН