ASP NET Core Model Binding

  Рет қаралды 150,422

kudvenkat

kudvenkat

Күн бұрын

Пікірлер: 107
@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.
@MosquitoMurderer
@MosquitoMurderer 5 жыл бұрын
I love when you say: "red squiggly"
@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 3 жыл бұрын
its confusing.
@roadtripping
@roadtripping 2 жыл бұрын
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.
@InamiLanzhu
@InamiLanzhu Ай бұрын
Another awesome video
@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.
@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....
@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?
@yasirirfan5262
@yasirirfan5262 7 ай бұрын
brilliant explanation.
@RicardoJnfrazao
@RicardoJnfrazao 3 жыл бұрын
Great tutorial.
@yashaswikeote7689
@yashaswikeote7689 5 жыл бұрын
Please make video on azure DevOps
@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
@AbuSayed-gf8gt
@AbuSayed-gf8gt 3 жыл бұрын
Great tutorial !
@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 2 жыл бұрын
you find solution?
@Dubeysaurabh592
@Dubeysaurabh592 Жыл бұрын
got any solution for this ?
@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
@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 4 жыл бұрын
In the Route you have {Id?}, but in the method parameter you called it 'empId' instead of 'Id'.
@turhansaltas9284
@turhansaltas9284 4 жыл бұрын
you are the king brother.
@mertkurt947
@mertkurt947 Жыл бұрын
you are awesome teacher , thank you
@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!
@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 });
@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.
@HungVo-fp7xk
@HungVo-fp7xk 5 жыл бұрын
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
@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
@МаксимИванов-ф8р
@МаксимИванов-ф8р 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.
@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.
@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 5 жыл бұрын
Same issue for me
@AbdullahTaherAbubakar
@AbdullahTaherAbubakar 5 жыл бұрын
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.
@vinayakh7730
@vinayakh7730 5 жыл бұрын
Thank you Venkat sir, you are awesome!
@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; }
@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.
@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
@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?
@aarbiayaz4744
@aarbiayaz4744 4 жыл бұрын
can anybody explain why do I need to change add transient to singleton?
@sakthir3892
@sakthir3892 5 жыл бұрын
Sir, nice explanation
@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.
@sunnysharma5635
@sunnysharma5635 3 жыл бұрын
Make one tutorial for web api using asp. Net core
@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.
@ShivamSingh-oe8tz
@ShivamSingh-oe8tz 4 жыл бұрын
I'm getting redirected to "create/home" instead of" home/details/id" can anyone tell why!
@ypwygk652
@ypwygk652 4 жыл бұрын
i have the same prolem
@debarghyachakraborty
@debarghyachakraborty 3 жыл бұрын
Try correcting the RedirectToAction method.
@jazicasri9248
@jazicasri9248 5 жыл бұрын
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
@ravichandragangavarapu1259
@ravichandragangavarapu1259 3 жыл бұрын
Sir u said everything about mvc by using asp dot net core
@lukedodson3441
@lukedodson3441 5 жыл бұрын
Got a null reference exception
@Pasaaydaan
@Pasaaydaan 4 жыл бұрын
I am also getting null reference exception
@lukedodson3441
@lukedodson3441 4 жыл бұрын
@@Pasaaydaan change the Home Controller constructor
@coolwaterdvr
@coolwaterdvr 5 жыл бұрын
Thanks Venkat.
@cesareemauritanie5288
@cesareemauritanie5288 4 жыл бұрын
Top Thank you !!!
@naodagere8210
@naodagere8210 4 жыл бұрын
Thank you very much.
@eugene-white-shark
@eugene-white-shark 3 жыл бұрын
Thank you!
@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 4 жыл бұрын
@@lukedodson3441 Inconsistent accessibility: parameter type 'IEmployeeRepository' is less accessible than method 'HomeController.HomeController(ILogger, IEmployeeRepository)
@RachitJain4U
@RachitJain4U 3 жыл бұрын
Thanks Sir :)
@saidamir4268
@saidamir4268 3 жыл бұрын
Thank you.
@salmanchowdarym1110
@salmanchowdarym1110 5 жыл бұрын
Thanks
@codeautomate8155
@codeautomate8155 5 жыл бұрын
thank you
@lukedodson3441
@lukedodson3441 5 жыл бұрын
Fixed it haha
@lukedodson3441
@lukedodson3441 5 жыл бұрын
@Marc Daniel P. Zornosa what you mean?
@chessgamesonline5867
@chessgamesonline5867 3 жыл бұрын
A bit confusing. :)
@МаксимИванов-ф8р
@МаксимИванов-ф8р 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
ASP NET Core model validation
10:19
kudvenkat
Рет қаралды 114 М.
AddSingleton vs AddScoped vs AddTransient
15:23
kudvenkat
Рет қаралды 217 М.
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН
Tuna 🍣 ​⁠@patrickzeinali ​⁠@ChefRush
00:48
albert_cancook
Рет қаралды 148 МЛН
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
Routing in ASP NET Core MVC
12:01
kudvenkat
Рет қаралды 191 М.
Repository pattern in asp net core
14:50
kudvenkat
Рет қаралды 308 М.
File upload in asp net core mvc
23:12
kudvenkat
Рет қаралды 189 М.
Implementing login functionality in asp net core
14:11
kudvenkat
Рет қаралды 172 М.
Form tag helpers in asp net core
11:12
kudvenkat
Рет қаралды 111 М.
Attribute Routing in ASP NET Core MVC
14:14
kudvenkat
Рет қаралды 147 М.
Add or remove users from role in asp net core
24:30
kudvenkat
Рет қаралды 85 М.
Model in ASP NET Core MVC
9:37
kudvenkat
Рет қаралды 208 М.
Creating roles in asp net core
12:20
kudvenkat
Рет қаралды 134 М.
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН