ERROR HANDLING In ASP NET Core | Getting Started With ASP.NET Core Series

  Рет қаралды 48,412

Rahul Nath

Rahul Nath

Күн бұрын

Hey Friends,
Exception handling or error handling is an important aspect of building applications. However much we want our applications to work fine, there will always be some unexpected cases. It's important that we handle these scenarios and return back appropriate messages. This is no different when building our APIs.
In this video, I will show you about exception handling in ASP NET Core Applications and the different ways we can handle them. I will also show you how to set up global error handling and the required middleware for that. Based on the feedback I received, I will also be showing some real-world examples of using Exception handling.
Additional Links:
🔗Handling Errors - docs.microsoft...
🔗Error Handling Approach (Ankit) - ankitvijay.net...
🔗Postman - www.postman.com/
Additional Watching
📹Model Binding - • MODEL BINDING in ASP.N...
📹 Return Types - • Controller ACTION RETU...
📹MIDDLEWARE - • MIDDLEWARE in ASP.NET ...
📹Dependency Injection - • DEPENDENCY INJECTION i...
📹Layering - • LAYERING in ASP.NET Co...
📹ASP NET Core Series - • ASP.NET Core
Come say hi! ✋
🌍 Blog - rahulpnath.com/
✉ Subscribe to my Newsletter - www.rahulpnath...
🐦Twitter - / rahulpnath
📸Instagram - / rahulpnath
🎥 Recording Setup and Workflow - www.rahulpnath...
Make sure to SUBSCRIBE to the channel. THANK YOU for helping me grow this channel !!

Пікірлер: 211
@bhuvankumarchauhan8958
@bhuvankumarchauhan8958 2 жыл бұрын
You will become the best teacher for .Net developers . Thanks for explaining thing in such a simple way
@RahulNath
@RahulNath 2 жыл бұрын
Thanks a ton Bhuvan. Hope you are enjoying the ASP Series bit.ly/asp-net-core-series
@uchitesting
@uchitesting Жыл бұрын
I love Command line since I used to be trained sysnet admin. Today as a developer on a VM I face terrible slowdowns with graphical tools. On a CLI I do the action in no time. I was not given a VS license for a while and I had to deal with .NET CLI. This is nice to know those options too. It may sound foolish but sometimes using dotnet CLI unlocked strange situations compiling through VS did not help. Less often it can be the other way around. Anyway I am here to learn about that error handling stuff. I just learnt there is a way to globally handle exceptions and that can be handy for a task I am given to setup logging. EDIT: After having watched the video it is not talking about what I heard about but that is very interesting.
@kumaramber6593
@kumaramber6593 3 жыл бұрын
I find your videos incredibly helpful for someone like me who is getting started in .net core.. Keep up the good work 👍
@RahulNath
@RahulNath 3 жыл бұрын
Thank you Kumar . happy to hear that. Do let know if there are specific topics that you would like covered.
@shahinquraishi9944
@shahinquraishi9944 2 жыл бұрын
P
@shahinquraishi9944
@shahinquraishi9944 2 жыл бұрын
@@RahulNath p
@rishabhmalhotra6474
@rishabhmalhotra6474 5 ай бұрын
just wanted to say that this is an excellent video for explaining global error handling. Kudos to you sir.
@RahulNath
@RahulNath 4 ай бұрын
Thank you Rishabh and glad you liked it! Hope you are liking the ASP Series bit.ly/asp-net-core-series
@n0wWhat
@n0wWhat 2 жыл бұрын
Great content, Quality presentation. Thanks for sharing
@RahulNath
@RahulNath 2 жыл бұрын
My pleasure! The full series for ASP NET is here in case you haven't come across them bit.ly/asp-net-core-series
@abhishekks6782
@abhishekks6782 3 жыл бұрын
Thank you so much sir for this beautiful explanation. This is such a complex topic but made it to look very easy 🙏.
@RahulNath
@RahulNath 3 жыл бұрын
You are most welcome Abhishek. Do check out the full series here if you haven't already kzbin.info/aero/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP And you can call me Rahul 😀
@techrelated2417
@techrelated2417 3 жыл бұрын
Exceptional Video on handling Exception !! Thank you Rahul !!
@RahulNath
@RahulNath 3 жыл бұрын
Thank you 😀
@Adarshsrivastavahigh
@Adarshsrivastavahigh 2 жыл бұрын
Wonderful demonstration of the concepts. Thank you very much sir.
@RahulNath
@RahulNath 2 жыл бұрын
You are most welcome Adarsh!!
@LogicOpsLab
@LogicOpsLab 3 жыл бұрын
You have really good quality content, Rahul. I was inspired from your content to create my own KZbin channel. Thanks a lot!
@RahulNath
@RahulNath 3 жыл бұрын
Wow that's so nice to hear. And super glad to know you started a KZbin channel. I will check out the videos there.
@LogicOpsLab
@LogicOpsLab 3 жыл бұрын
@@RahulNath My pleasure, Rahul.
@alwaseem5309
@alwaseem5309 Жыл бұрын
As usual, highly quality.
@RahulNath
@RahulNath Жыл бұрын
Glad you think so!
@anurag3487
@anurag3487 3 жыл бұрын
nice one Rahul. Well explained.
@RahulNath
@RahulNath 3 жыл бұрын
Happy you like it Anurag! (Still working out the security related topics. Lots of reading to do 😀)
@anurag3487
@anurag3487 3 жыл бұрын
@@RahulNath I have also started reading, and have understood a lot of security related concepts. Please take your time.
@kakmca
@kakmca 2 жыл бұрын
Oh my God, you are rocking man! Thank you very much for this beautiful video. This is what exactly I'm looking for.
@RahulNath
@RahulNath 2 жыл бұрын
Glad I could help! Do check out the full series here bit.ly/asp-net-core-series
@soulfabuk
@soulfabuk 2 жыл бұрын
Fantastic video as always Rahul. Plenty of detail that is explained in a clear but thorough way. Thanks for helping the developer community!
@RahulNath
@RahulNath 2 жыл бұрын
Great to hear that, thank you.
@sirpasricharan4986
@sirpasricharan4986 3 жыл бұрын
Great Explanation Rahul, Thankyou so much
@RahulNath
@RahulNath 3 жыл бұрын
Thank you Sirpa!
@zarazada
@zarazada 3 жыл бұрын
The best teacher ever
@RahulNath
@RahulNath 3 жыл бұрын
Thank you Zarifa. Hope you have checked out the full series kzbin.info/aero/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP Do let know if you have any topic suggestions.
@deepakmitawa8106
@deepakmitawa8106 2 жыл бұрын
Thank you Rahul to made this video. Very good explainaion.
@RahulNath
@RahulNath 2 жыл бұрын
Thanks and welcome Deepak!
@vineethkumartg4111
@vineethkumartg4111 3 жыл бұрын
Hi Rahul, Your Video contents are really useful and helpful with Realtime cases, It would be better if you could also use slides .So that we will understand some theory part as well. At the start of the videos you can show the Agenda, explanation of the concepts and at the last you can summarizes what are all the steps required or done to implement the logic.. Can you also provide a Video on Serilog,intergrate Serilog with AWS elastic search and Kibana.
@RahulNath
@RahulNath 3 жыл бұрын
Glad you like it Vineethkumar. And a great suggestion on the slides. I will post a poll on the channel to see the general opinion too. Slides will add in more effort on my side, but happy to do if a lot of people think it will be useful 😀 Added Serilog to my list. Hope you have watched my video on Logging kzbin.info/www/bejne/mqmlnXWiqap3iNU Thank you again for the suggestion and the feedback!
@Azcraz
@Azcraz 3 жыл бұрын
Great video and explanation once again!
@RahulNath
@RahulNath 3 жыл бұрын
Thanks again!
@ashutoshsrivastava2275
@ashutoshsrivastava2275 3 жыл бұрын
Great !! I have watched your other videos also. keep rocking. Thanks for your efforts.
@RahulNath
@RahulNath 3 жыл бұрын
Thanks a ton, glad you like them!
@syedabdullah965
@syedabdullah965 2 жыл бұрын
Hey Rahul, Thanks for the video. Just want to ask that how to register middle ware in .net 6 as there is no Startup.cs file in this version. So ?
@RahulNath
@RahulNath 2 жыл бұрын
It's slightly changed places - In case you didn't find it already - docs.microsoft.com/en-us/aspnet/core/fundamentals/middleware/?view=aspnetcore-6.0&WT.mc_id=AZ-MVP-5003875 Does that help?
@nirajjoshi3349
@nirajjoshi3349 2 жыл бұрын
superb video I found on you tube
@RahulNath
@RahulNath 2 жыл бұрын
Thanks and welcome. The full series on ASP is here bit.ly/asp-net-core-series
@nirajchandrajoshi
@nirajchandrajoshi 2 жыл бұрын
@@RahulNath Thanks a ton you replied me. I will view this.
@RahulNath
@RahulNath 2 жыл бұрын
@@nirajchandrajoshi Sure Niraj. Let me know in case you have specific questions, suggestions or feedback
@aaqibkhan8360
@aaqibkhan8360 2 жыл бұрын
Very well explained!
@RahulNath
@RahulNath 2 жыл бұрын
Glad you liked it Aaqib. Hope you are enjoying the series bit.ly/asp-net-core-series
@psmith189
@psmith189 2 жыл бұрын
Great Explanation!
@RahulNath
@RahulNath 2 жыл бұрын
Glad it was helpful! Do check the full series bit.ly/asp-net-core-series I'm sure you will like it!
@GrtAngel
@GrtAngel Жыл бұрын
That's awesome 👍
@RahulNath
@RahulNath Жыл бұрын
Thank you Avinash! Hope you are liking the series 👍
@fastturtle8429
@fastturtle8429 3 жыл бұрын
Great detailed video sir, thanks for sharing
@RahulNath
@RahulNath 3 жыл бұрын
So happy to hear that Mahmadhusen. Do check out the full series here if you haven't already kzbin.info/aero/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP And you can call me Rahul 😀
@akhilkumarp
@akhilkumarp 2 жыл бұрын
Thanks for the detailed explanation, keep doing more🎉
@RahulNath
@RahulNath 2 жыл бұрын
Sure and happy you liked it Akhil. Hope you are enjoying the series bit.ly/asp-net-core-series
@akshayanvekar8713
@akshayanvekar8713 3 жыл бұрын
You earned a subscriber. Nice explanation.
@RahulNath
@RahulNath 3 жыл бұрын
Glad you like it Akshay. Do check out the other videos in this series kzbin.info/aero/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP Let know in case you want any particular topics to be covered.
@akshayanvekar8713
@akshayanvekar8713 3 жыл бұрын
@@RahulNath Can you create a Unit Test tutorial for asp.net core
@RahulNath
@RahulNath 3 жыл бұрын
@@akshayanvekar8713 Sure yes. Coming up soon! Meanwhile do checkout my AutoFixture playlist kzbin.info/aero/PL59L9XrzUa-mItWClbGuMEK5oQpU2onCq It's very helpful with writing tests.
@onyoursideabsolutely2268
@onyoursideabsolutely2268 2 жыл бұрын
Hi Rahul, Thanks a lot for to the point videos. I really appreciate the content and the way you teach. I am able to understand the concept with the way you explain it. Thanks!
@fahmifarhat7076
@fahmifarhat7076 2 жыл бұрын
Thanks a lot Rahul. You have made it very clear for me !
@RahulNath
@RahulNath 2 жыл бұрын
Most welcome Fahmi!
@ramashankar2750
@ramashankar2750 3 жыл бұрын
Certain Exceptions need additionally a code mining strategy and we can use the ctor/BaseTrace (Assembly.GetCallingAssembly().Getname().Name ) added to the middleware to deliver a multilevel ring trace on a circular queue available on production mode, to locate the path of code.
@RahulNath
@RahulNath 3 жыл бұрын
yes adding in more logs helps, I usually have a request id to correlate across all the messages.
@ramashankar2750
@ramashankar2750 3 жыл бұрын
@@RahulNath Design for a Pitstop of Diagnostics to achieve functionality, refer you to the book Art of Programming by Edgar Dijkstra.
@RahulNath
@RahulNath 3 жыл бұрын
@@ramashankar2750 Great will check it out!
@AngelPerez-pp2hj
@AngelPerez-pp2hj 2 жыл бұрын
Thank you so much!!! Greetings and blessings from Perú! 👍 👍
@RahulNath
@RahulNath 2 жыл бұрын
Thank you too!
@TheMezanine
@TheMezanine 2 жыл бұрын
Thanks a lot for the great video with clear explainations!!!!
@RahulNath
@RahulNath 2 жыл бұрын
You are welcome and glad you liked it Medoune! The full series for ASP is here bit.ly/asp-net-core-series
@subrataranjanpal6518
@subrataranjanpal6518 3 жыл бұрын
Really helpful your information!! Thank U.
@RahulNath
@RahulNath 3 жыл бұрын
Glad they are helping Subrata!
@bloopers2967
@bloopers2967 3 жыл бұрын
Damn bro your explanation is awesome, need more videos on aap.net core❤️❤️❤️ and you deserve more subscribes
@RahulNath
@RahulNath 3 жыл бұрын
Thank you for the love and glad you like it. Hope you checked out other videos in this series kzbin.info/aero/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP Do let know if you have specific topics that needs to be covered.
@bloopers2967
@bloopers2967 3 жыл бұрын
@@RahulNath Yes watching the whole series, preparing for an interview
@bloopers2967
@bloopers2967 3 жыл бұрын
@@RahulNath Yes, can you make detailed videos on both generic and non generic collections. More focused on hashmap and dictionary
@raagasongs
@raagasongs 3 жыл бұрын
superb..
@RahulNath
@RahulNath 3 жыл бұрын
Thank you Rajesh!
@mayureshm2534
@mayureshm2534 3 жыл бұрын
keep it bro, its awesome!!
@RahulNath
@RahulNath 3 жыл бұрын
Thank you Mayuresh! Do check out the full series here kzbin.info/aero/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP
3 жыл бұрын
Thank you very much it was just what I needed to implement in my API and you made it very simple, thanks again!
@RahulNath
@RahulNath 3 жыл бұрын
Glad it helped Joshué! Do check out my full series here bit.ly/asp-net-core-series I'm sure you will like it!
@bhavyashah8847
@bhavyashah8847 3 жыл бұрын
This is something I was looking for my project. Handling error from a centralised system will surely save a alot of development efforts. Just had one doubt Why did you make your domain exception class as abstract ? What if, we don't make it abstract?
@RahulNath
@RahulNath 3 жыл бұрын
Thank you Bhavya. It's optional to mark it as abstract. (22:25) Only if you want to make sure across the code base you want more specific exceptions to be created instead of using the base class always. Hope that helps.
@0GERA0
@0GERA0 2 жыл бұрын
whats the difference with this error handling to the controller filter globalexception : options.Filters.Add(); or which is the best way?, thanks for your videos
@adhivenkatesh3431
@adhivenkatesh3431 2 жыл бұрын
Hi Rahul , great effort , thanks for your video.
@RahulNath
@RahulNath 2 жыл бұрын
Thanks and welcome Adhi. Happy New Year. Check out the full series here which has lot more such videos bit.ly/asp-net-core-series
@adhivenkatesh3431
@adhivenkatesh3431 7 ай бұрын
@@RahulNath Thanks Rahul , your videos are always different and advanced
@RahulNath
@RahulNath 7 ай бұрын
@@adhivenkatesh3431 Thank you Adhi and happy that you find them useful.
@harishkommuri5350
@harishkommuri5350 3 жыл бұрын
Thanks for the Knowledge Share, I found it useful. I have a question - In ExceptionHandler Middleware, the catch blocks grows as many we have different Domain Exceptions, could you suggest on A better way to handle, as catch blocks grows with different domain exception classes? This is on the Interview Questions I have got, please suggest..
@RahulNath
@RahulNath 3 жыл бұрын
Thank you Harish. The ExceptionHandler implementation in this blog post covers once such option to clean up the long list ankitvijay.net/2021/04/21/consistent-error-handling/ Let know if something like that is what you are looking for.
@suryazn4575
@suryazn4575 Жыл бұрын
Hi Rahul, I appreciate your presentation, have few doubts can we use Enum instead of Summaries Array?
@NithinPrathapan
@NithinPrathapan Жыл бұрын
Very useful video. Rahul, is there any way we could capture the managed errors as well? For example, if we want to perform a global cache reset if some managed if exceptions occurred. In our case, it is already captured by the library we are using.
@mohsenghahremani508
@mohsenghahremani508 2 жыл бұрын
How do you implement this in an Azure function since the azure function has some work around? Can you explain ?thanks.
@RahulNath
@RahulNath 2 жыл бұрын
With Azure Function since the code is more isolated I would handle it within the function handler code. if there are a lot of functions, I might add a base class to handle API calls and implement common handling there. I do have couple of videos around Azure Functions www.rahulpnath.com/blog/getting-started-with-azure-functions/ www.rahulpnath.com/blog/dependency-injection-in-azure-functions/ Let me know if that answers your question or if you have additional questions.
@rahulmishra111
@rahulmishra111 2 жыл бұрын
It would be better if you can give download also for the shown projects ... Great video
@RahulNath
@RahulNath 2 жыл бұрын
Usually I have the path to the repo in the description. Missed uploading this one. Will see if I can find it and upload it again. All repos are usually here rahulpnath.visualstudio.com/KZbin%20Samples/_git/aspnet-startup
@madhujonnabattla6479
@madhujonnabattla6479 2 жыл бұрын
Hi Rahul, Your Videos are really awesome, I would like to hear a solution for the exception in the Finally block, How can we handle these exceptions in the real project. Thanks in advance.
@RahulNath
@RahulNath 2 жыл бұрын
Thank you Madhu. When you are catching an Exception the code likely you are expecting for it in that case what would you want the code to do? If you can explain the scenario a bit more maybe I could help.
@ChandanKumar-es7bz
@ChandanKumar-es7bz 3 жыл бұрын
Hi Rahul. I have watched your videos recently and they are really good
@RahulNath
@RahulNath 3 жыл бұрын
Thank you Chandan. Happy they are helping. Here is the full ASP Series in case you missed it bit.ly/asp-net-core-series
@ChandanKumar-es7bz
@ChandanKumar-es7bz 3 жыл бұрын
​@@RahulNath​ Thanks Rahul. Can you please make a video on role based authentication in web api using microsoft graph
@RahulNath
@RahulNath 3 жыл бұрын
@@ChandanKumar-es7bz Is this what you are looking for? kzbin.info/www/bejne/fofVpnWNqrChj9k www.rahulpnath.com/blog/dot-net-core-api-and-azure-ad-groups-based-access/
@susus999
@susus999 3 жыл бұрын
Hi@rahul....I have deployed dotnet3.1 project which have .msi setup...when I am deploying .msi is not getting triggered and the deployment fails saying website not found....Any suggestions 🙏Thanks in advance
@RahulNath
@RahulNath 3 жыл бұрын
Hey Sai, that is a broad question. Why are you using MSI to deploy a website? Where are you installing this to? Is this a MSI distributed for your clients?
@susus999
@susus999 3 жыл бұрын
@@RahulNath I am installing to the web app on azure.....Yes it is distributed....I am giving silent installation command on inline script post deployment which dint work and also bat command also failed.....Thanks for all the learning you are providing 🙏
@naveenbaghel2936
@naveenbaghel2936 2 жыл бұрын
I can see your MVP award in background....
@RahulNath
@RahulNath 2 жыл бұрын
Yeah it's there on the shelf behind me 😀
@AbdulSamad-by4fx
@AbdulSamad-by4fx 2 жыл бұрын
Thank you sir for the great explanations :)
@RahulNath
@RahulNath 2 жыл бұрын
Most welcome! Do checkout the full playlist here bit.ly/asp-net-core-series
@rohan4rich
@rohan4rich 3 жыл бұрын
Is it mandatory to return concrete type if we are implementing our custom ExceptionMiddleware from action method or we can use IActionResult also ?
@RahulNath
@RahulNath 3 жыл бұрын
Hey Rohan, You can very well return IActionResult. Check out the differences between those in this video where I talk about it in detail kzbin.info/www/bejne/hWq9gmOFbtp9aKc. Do let me know in case you have additional questions about this.
@callegarip
@callegarip 3 жыл бұрын
Thanks for the video. I have a question. What if I have multiple ExceptionHandlingDomains? (maybe I have a few different projects to handle different areas of the business in my app) How my ExceptionHandlingMiddleware is aware of what ExceptionHandlingDomain to use?
@RahulNath
@RahulNath 3 жыл бұрын
Might need more details. But the handler can be extended to switch case on any Exception Type. Check this gist (from a friend of mine) gist.github.com/ankitvijay/168c41f3abb3e817375be05e7b2e7083#file-2_exceptionhandler-cs for an example Is that what you were looking for? What issues are you particularly facing?
@callegarip
@callegarip 3 жыл бұрын
@@RahulNath I am not running into issues yet b I just started implementing error handling and I watched your video and I’d like to implement it. So let me give you more details. I have a multi layer project. I called ManagerXXX to a project that handle certains things in the app. I think you called it Domain project. You could also think my ManagerXXX like my services. So I want to create a custom ManagerXXXHandlingException for each of those projects I have. My question was how can I make my ExceptionHandlerMidleware to be smart to decide what type of exception to use. I know that if I just keep adding CATCH CATCH CATCH… for all the ones I have on each manager will work, but that seems to be odd. I was wondering if there is a pattern for this scenario.
@callegarip
@callegarip 3 жыл бұрын
I just saw the gist in your link. I think there is something there that could work for me. I will take a look at it closer.
@RahulNath
@RahulNath 3 жыл бұрын
@@callegarip Sure ok. let me know how that goes and if you have additional questions.
@callegarip
@callegarip 3 жыл бұрын
@@RahulNath thank you very much. You are awesome!
@DWCmoose
@DWCmoose 10 ай бұрын
But isn't wrapping await next(context) in the try catch the same as having try catch all over your controller actions? this would cause a performance hit across the application won't it?
@elCOMPAiler
@elCOMPAiler 7 ай бұрын
Amazing explanation thanks a lot Rahul. New subscriber here!
@RahulNath
@RahulNath 7 ай бұрын
Glad you are liking the content.
@sandeep19830
@sandeep19830 3 жыл бұрын
Hi Rahu Do you have microservices and Circuit Breaker Pattern vedio
@RahulNath
@RahulNath 3 жыл бұрын
I don’t have one specific to micro services. But I talk about this pattern in this video. Is that what you were looking for ? kzbin.info/www/bejne/sGe8lIhmhbySb6c
@balajir391
@balajir391 3 жыл бұрын
Filters and Middleware. When should we use filters ? When should we use Middleware. ?
@RahulNath
@RahulNath 3 жыл бұрын
The official docs here has some good suggestions around that _"Prefer middleware for exception handling. Use exception filters only where error handling differs based on which action method is called. "_ Read more here 👉 docs.microsoft.com/en-us/aspnet/core/mvc/controllers/filters?view=aspnetcore-5.0#exception-filters Let me know if you have further questions.
@panirajn
@panirajn 3 жыл бұрын
very nice tutorial
@RahulNath
@RahulNath 3 жыл бұрын
Thanks for watching Paniraj!
@asht3118
@asht3118 3 жыл бұрын
Great video
@RahulNath
@RahulNath 3 жыл бұрын
Glad you like it Ash! Do check out my other videos in this series 😀
@vinothrajendran858
@vinothrajendran858 3 жыл бұрын
Hi Bro. Thanks for this video. I have one doubt. Can we simply use throw new exception kinds inside the code ? Is that a proper way?
@RahulNath
@RahulNath 3 жыл бұрын
Sure you can - but it becomes limiting. Having specific or categorized domain exceptions allows you to capture and handle for it at central handlers. This makes it more powerful. Also when you look at logs you can immediately filter out based on the type of exception. So my preference is generally to create specific exceptions, but nothing stopping you from doing new Exception("Message"). Hope that helps
@vinothrajendran858
@vinothrajendran858 3 жыл бұрын
@@RahulNath Thanks bro. Continue doing Azure related stuffs with .Net core. And also do containerization
@RahulNath
@RahulNath 3 жыл бұрын
@@vinothrajendran858 Cool thanks
@syamchandar9780
@syamchandar9780 2 жыл бұрын
Hi Rahul, After seeing this video I got confused between Middleware and filters, could you please make a video on this difference and when to use Middleware and filters.
@RahulNath
@RahulNath 2 жыл бұрын
Does this help you Syam? learn.microsoft.com/en-us/aspnet/core/mvc/controllers/filters?view=aspnetcore-6.0&WT.mc_id=AZ-MVP-5003875#use-middleware-in-the-filter-pipeline And this SO post also explains it a bit more stackoverflow.com/questions/42582758/asp-net-core-middleware-vs-filters
@DjHomerr
@DjHomerr Жыл бұрын
Hello Rahul, could you explain why the lifetime of a Exception Handling Service is transient and not scoped?
@RahulNath
@RahulNath Жыл бұрын
since there is no state to be managed in there. Any reason you are looking at why it needs to be scoped?
@DjHomerr
@DjHomerr Жыл бұрын
@@RahulNath No particular reason. I just couldn't understand why transient, and what does the lifetime of a exception handling service even mean? I have my web api with a couple of services that just deal with basic crud operations involving a database, and scoped lifetime seemed like a good choice for those. So i thought the exception handling middleware service would be the same.
@RahulNath
@RahulNath Жыл бұрын
they make sense only if you need to keep context + state in the context of that scope. In this case it isn't required - Do check out my DI video kzbin.info/www/bejne/j4OZeZ6sg6ejjpY And other videos in this series bit.ly/asp-net-core-series
@DjHomerr
@DjHomerr Жыл бұрын
@@RahulNath Thank you very much for the response!
@vineeths1710
@vineeths1710 3 жыл бұрын
Hi i have created an asp.net core web api and added custome middleware but its still throwing the exception before going to middleware catch block..do wee need exception filter to handle that?
@RahulNath
@RahulNath 2 жыл бұрын
Yes I think so - hope you were able to catch that?
@keerthang5557
@keerthang5557 3 жыл бұрын
Hi sir, can you make a tutorial video on worker service?
@RahulNath
@RahulNath 3 жыл бұрын
Hey Keerthan, Which worker services are you referring to? And you can call me Rahul 😀
@keerthang5557
@keerthang5557 3 жыл бұрын
@@RahulNath It's worker service in asp.net core ( Hosted services)
@RahulNath
@RahulNath 3 жыл бұрын
@@keerthang5557 Thank you Keerthan for clarifying. I am guessing this is what you are referring to? docs.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-5.0&tabs=visual-studio Great Suggestion. Yes, I will do one on that.
@keerthang5557
@keerthang5557 3 жыл бұрын
@@RahulNath Yes brother, that's the one
@RahulNath
@RahulNath 3 жыл бұрын
@@keerthang5557 Sure will do!
@asht3118
@asht3118 3 жыл бұрын
Why you use Rider not visual studio?
@RahulNath
@RahulNath 3 жыл бұрын
Because it is easier to navigate into library implementation code, like I do at 4:56
@Blr046
@Blr046 3 жыл бұрын
Is it possible to pass multiple parameters to "DomainNotFoundException" class and access those parameters in ExceptionHandlingMiddleware class ?
@RahulNath
@RahulNath 3 жыл бұрын
Sure. Any number of parameters and types as you wish. it’s a custom type, so you can control it. let me know if you are running into any issues
@Blr046
@Blr046 3 жыл бұрын
@@RahulNath Yes, I am able to pass the arguments, but I don't know how access those parameters in global ExceptionHandlingMiddleware class. I want to print the exception in the log in common place.
@raagasongs
@raagasongs 2 жыл бұрын
Hi Rahul, How are you? If you get a chance please do videos on .Net core microservices
@RahulNath
@RahulNath 2 жыл бұрын
I am good Rajesh and hope you are too. Thank you for reminding me on this, I do have some planned but haven't reached to it yet. Any cloud tech preferences for you on it, or are you ok if it's either Azure or AWS?
@raagasongs
@raagasongs 2 жыл бұрын
@@RahulNath - Thanks for reply. I am fine with Azure. I will wait for microservices videos.. Finally I like your videos and keep it up. It would help more peoples like me.
@RahulNath
@RahulNath 2 жыл бұрын
@@raagasongs Thank you !!
@balajithirunavukarasu7494
@balajithirunavukarasu7494 3 жыл бұрын
please take session for .net core MVC
@RahulNath
@RahulNath 3 жыл бұрын
Thank you for the suggestion Balaji. Any specific topics you would like covered? (Not sure how soon I will do it though, since I've not been working much on MVC)
@balajithirunavukarasu7494
@balajithirunavukarasu7494 3 жыл бұрын
@@RahulNath Thank You. can you take real time example for filters like Authorization Filter and , Exception Filter in .NET core
@sagerofgyan
@sagerofgyan 7 ай бұрын
how to handle 403 in .net core web api
@saritalad8923
@saritalad8923 2 жыл бұрын
Great explanation. Rahul, can u sovle my problems, I am 60+ woman, so I find your speed of teaching somewhat faster. But definitely best. My problem is As follows I want to make an apl to be cobsumed by angular, it has entity, employee with contenment if address, so how to write put method so that data of employee and address get updated togather.
@saritalad8923
@saritalad8923 2 жыл бұрын
Employee with id, name, salary and addressid as fireign key, with another entity address id, street, city, pin
@RahulNath
@RahulNath 2 жыл бұрын
Happy to help. What issues are you facing in particular?
@joe-sydney-au
@joe-sydney-au 2 жыл бұрын
You should tell us you are a 16yo girl, not 60+ woman ! Then everyone in here will jump to help you 😍😁😆🤣
@i.paradox
@i.paradox 2 жыл бұрын
Shower of love Rahul
@RahulNath
@RahulNath 2 жыл бұрын
Thank you Sahil! Do check out the full series if you haven't already bit.ly/asp-net-core-series
@sureshp34
@sureshp34 2 жыл бұрын
Hi Rahul, I would like you to post a new video on "CancellationToken" in HttpClient request.
@RahulNath
@RahulNath 2 жыл бұрын
Great suggestion Suresh. This is something on my list. I will try and do something on it.
@sureshp34
@sureshp34 2 жыл бұрын
Thank you@@RahulNath
@1212Times
@1212Times 2 жыл бұрын
YOU ARE PERFECT
@RahulNath
@RahulNath 2 жыл бұрын
Haha definitely not, but thank you 😀 Hope you are enjoying the series bit.ly/asp-net-core-series
@smrsgv
@smrsgv Жыл бұрын
👍
@RahulNath
@RahulNath Жыл бұрын
😀
@NikithaGurram
@NikithaGurram Жыл бұрын
Hai,rahul please explain the concepts in realtime examples.... don't use wheatherforcate for everytime
@RahulNath
@RahulNath Жыл бұрын
Thank you Nikitha for the feedback. The idea with these videos was to explain concepts from a known starting point. I figured the existing default template app was the best place for this. If not it's hard to set the right context to explain the different concepts from a fully setup project. I have tried to include as much real world concepts/problems you come across, but would definitely would have missed heaps. Anything in particular you are looking for or you feel missing?
@NikithaGurram
@NikithaGurram Жыл бұрын
@@RahulNath thank you for your response rahul but what i am saying is if you can apply the concepts in curd operations i think its helps a lot for freshers... That's way i am asking any way your vedio's helps me alot thank you rahul
@RahulNath
@RahulNath Жыл бұрын
@@NikithaGurram Sure will keep that in mind - Glad you find the videos useful Nikitha 👍
@aaronbcj
@aaronbcj 4 ай бұрын
One request, is to make your face circle small so it doesn't hide the code.
@RahulNath
@RahulNath 4 ай бұрын
Thank you for the feedback! I have been more cautious about this in my recent videos and making sure it does not block important parts! Hope you are enjoying the series bit.ly/asp-net-core-series
@aaronbcj
@aaronbcj 4 ай бұрын
As mostly I use mobile to watch while commuting, it becomes even harder but good that you are aware. 👍
@RahulNath
@RahulNath 4 ай бұрын
@@aaronbcj Yup makes sense / let me know if you face the same problem in more recent videos! Thanks again for the feedback!
@chinjuskitchen4234
@chinjuskitchen4234 2 жыл бұрын
Can u add more videos about aks
@RahulNath
@RahulNath 2 жыл бұрын
Thank you for the suggestion. Not sure how soon though, I havent been doing a lot of aks.
@RahulNath
@RahulNath 2 жыл бұрын
Great channel you have got yourself Chinju! And great to see you are from Kerala too (I am as well 😀)
@usamatahir394
@usamatahir394 3 жыл бұрын
great (y)
@RahulNath
@RahulNath 3 жыл бұрын
Thank you Usama 😀
@AbhinavSingh-ov7pj
@AbhinavSingh-ov7pj 3 жыл бұрын
This is good but model validation error are not caught in above solution. Just need code where we can caught exception and Model validation at same place so that api can return common response.
@RahulNath
@RahulNath 2 жыл бұрын
Hope you were able to resolve this.
@AbhinavSingh-ov7pj
@AbhinavSingh-ov7pj 2 жыл бұрын
@@RahulNath I have not got solution
@adityaghosalkar431
@adityaghosalkar431 2 жыл бұрын
Rahul is just awesome guy from 2050
@RahulNath
@RahulNath 2 жыл бұрын
Haha !! Thank you and happy you liked it. Check out the full series here bit.ly/asp-net-core-series
@joe-sydney-au
@joe-sydney-au 2 жыл бұрын
It was a lot easier with the previous .NET v4.x; We could do this out of the box : 1) return Request.CreateErrorResponse(HttpStatusCode.NotFound, message); 2) throw new HttpResponseException( Request.CreateErrorResponse( HttpStatusCode.NotFound, message) ); Can anyone show an example where the http Client Library (e.g. axios, fetch) can actually capture the status-code, and custom message thrown by the web-api DOT NET CORE BULLSHIT?
@utkarshdubey7993
@utkarshdubey7993 11 ай бұрын
triggered inaan hum aapse milne a rahe hain march mein
@RahulNath
@RahulNath 11 ай бұрын
sorry, didn't understand?
@prototype8861
@prototype8861 3 жыл бұрын
Indians start explaining anything by first creating a project. You all.shall.see one more time how to create a project. And name it "my project".
@RahulNath
@RahulNath 3 жыл бұрын
Not sure about all "Indians" Emre, I do that to start from familiar grounds to someone new to a concept. This helps teach more easily than starting from a big code base. Not sure if you watched past the project creation and had any suggestions on that. Thank you!
@techpc5453
@techpc5453 Жыл бұрын
@mayurbanta
@mayurbanta 2 жыл бұрын
Awesome content, Thank you ! Can we have something like this in a method. Public int SaveEntity() { try { context.SaveChanges(); } catch(DbUpdateException exception) { throw new SomeDomainException(exception?.InnerException); } } and catch that "SomeDomainException" in middleware.
@RahulNath
@RahulNath 2 жыл бұрын
Yes, you could do that - nothing stopping you from doing that. It might soon be a lot of exceptions depending on the granularity of these classes.
@mayurbanta
@mayurbanta 2 жыл бұрын
@@RahulNath Thanks for the reply.
@MrRikiJane
@MrRikiJane 2 жыл бұрын
awesome video
@RahulNath
@RahulNath 2 жыл бұрын
Glad you enjoyed it and hope you are enjoying the full series bit.ly/asp-net-core-series
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 26 МЛН
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 46 МЛН
Don't throw exceptions in C#. Do this instead
18:13
Nick Chapsas
Рет қаралды 263 М.
Elegant Global Error Handling Using Middleware In ASP.NET Core
13:58
Milan Jovanović
Рет қаралды 90 М.
.NET 6 - Web API Caching with Redis ⏲🌐
1:04:23
Mohamad Lawand
Рет қаралды 38 М.
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 26 МЛН