OPTIONS PATTERN in ASP.NET Core | Getting Started With ASP.NET Core Series

  Рет қаралды 18,900

Rahul Nath

Rahul Nath

3 жыл бұрын

When building applications, it often needs access to different configurations - be it a connection string to a database, ClientId, Secret, external API URLs, tokens, etc. By keeping these values in the application's configuration, we can use different values for different environments. ASP NET Core provides rich support for adding various configuration sources including appsettings.json, environment variables, key vault, and many more.
In this video, let's learn how to consume these configuration values from the application code you write, using the Options pattern in ASP NET Core. We will see the different interfaces supported by the pattern IOptions, IOptionsSnapshot, and see the differences between them. We can also add validations to ensure configuration values exist and enforce constraints on the values configured.
🔗Source Code - rahulpnath.visualstudio.com/D...
🔗 Options Pattern - docs.microsoft.com/en-us/aspn...
Additional Watching
📹How To Use HTTP CLIENT IN ASP NET CORE - • How To Use HTTP CLIENT...
📹DEPENDENCY INJECTION in ASP.NET Core - • DEPENDENCY INJECTION i...
📹CONFIGURATION in ASP.NET Core - • CONFIGURATION in ASP.N...
📹ASP NET Core Series - • ASP.NET Core
Come say hi! ✋
🌍 Blog - rahulpnath.com/
✉ Subscribe to my Newsletter - www.rahulpnath.com/subscribe
🐦Twitter - / rahulpnath
📸Instagram - / rahulpnath
🎥 Recording Setup and Workflow - www.rahulpnath.com/blog/youtu...
Video Edited by my wife, Parvathy 😍
Make sure to SUBSCRIBE to the channel. THANK YOU for helping me grow this channel !!

Пікірлер: 108
@ajaysonar1675
@ajaysonar1675 3 жыл бұрын
Best till date, exactly to the point without any clutter. Thanks !
@RahulNath
@RahulNath 3 жыл бұрын
Thank you Ajay!
@yuvrajingale526
@yuvrajingale526 5 күн бұрын
Very informative Video, keep the good work continue🎉
@RahulNath
@RahulNath 5 күн бұрын
Thank you Yuvraj and glad you like it. Hope you are liking the ASP Series bit.ly/asp-net-core-series
@payalsharma1413
@payalsharma1413 3 жыл бұрын
Found this video randomly and after that I watched most of your videos. They are very helpful and nicely explained.
@RahulNath
@RahulNath 3 жыл бұрын
Glad you like them Payal and for letting me know. Do let know if there are any topics you want covered and I will try add more videos.
@harishe6069
@harishe6069 2 жыл бұрын
Same to same..
@kailas141987
@kailas141987 Жыл бұрын
Best series in .Net core web API. Anyone can learn all concepts by watching this series. It helped me in the interview process. Please give real-world examples along with explanation so we can easily co-relate concepts.
@soulfabuk
@soulfabuk Жыл бұрын
Another great video Rahul, just loved the way you went through separating out variables from the interpolated string before then moving them into the appsettings file. The step-by-step nature makes your videos so much easier to follow than many others!! Keep up the fantastic work.
@RahulNath
@RahulNath Жыл бұрын
Glad you liked it and thank you for supporting the channel! Hope you are enjoying the full series. Feel free to reach out if you have specific questions or suggestions. 😀
@jhlee111
@jhlee111 2 жыл бұрын
I appreciate your concise way of explaining concepts and when and how it goes wrong in detail. The latter gives me good understanding about why we use it. Thanks!
@RahulNath
@RahulNath 2 жыл бұрын
Glad it was helpful! And yes I try to introduce the concepts progressively to make it easier to relate to. Happy you found that particular way useful. Also thank you for supporting me by becoming a member!
@richardekeopara886
@richardekeopara886 3 жыл бұрын
Terse and straight to the point. I love your style. Please keep it up!
@RahulNath
@RahulNath 3 жыл бұрын
Thank you Richard! Happy that you like the style and they are helpful.
@88spaces
@88spaces 2 жыл бұрын
This presentation is clear and concise and gets right to the point.
@RahulNath
@RahulNath 2 жыл бұрын
Thank you Chris. Do check the full series here kzfaq.info/sun/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP I’m sure you’ll like it . Do let know in case you get to watch any 😀
@bward4126
@bward4126 2 жыл бұрын
Wow. This was EXACTLY what I needed. Thank you.
@RahulNath
@RahulNath 2 жыл бұрын
You're so welcome! Do check out the full series here bit.ly/asp-net-core-series
@vaelinalsorna1649
@vaelinalsorna1649 2 жыл бұрын
Good video. Straight to the point and well-spoken.
@RahulNath
@RahulNath 2 жыл бұрын
Thank you Vaelin! Do check out the full series here bit.ly/asp-net-core-series I am sure you'll like it!
@ChosenHandle
@ChosenHandle 3 жыл бұрын
Great video. Well structured and informative. Thank you!
@RahulNath
@RahulNath 3 жыл бұрын
Glad you enjoyed it! Do check out the other ones in this series - kzfaq.info/sun/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP
@melk48111
@melk48111 3 жыл бұрын
awesome Rahul
@RahulNath
@RahulNath 3 жыл бұрын
Thank you Melvis! Do checkout my other videos in this Series kzfaq.info/sun/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP. Do let know if there are any specific areas to be covered
@iceneno2491
@iceneno2491 4 ай бұрын
Excellent!
@RahulNath
@RahulNath 4 ай бұрын
Glad you liked it! Hope you are enjoying the series bit.ly/asp-net-core-series
@DrGaurangGupta
@DrGaurangGupta Жыл бұрын
Awesome explanation. Had been struggling to work out the whole concept and you made it crystal clear. Same as your video on dependency inversion principle. Love your content!
@RahulNath
@RahulNath Жыл бұрын
Glad it helped Gaurang! Do check out the full ASP Series in case you haven't bit.ly/asp-net-core-series
@ashamarias
@ashamarias 3 жыл бұрын
Great video Rahul. Well explained!
@RahulNath
@RahulNath 3 жыл бұрын
Glad you liked it!
@albertszymanski7177
@albertszymanski7177 8 ай бұрын
Awesome video. Well-structured and informative. Definitely the best video on this topic out there.
@RahulNath
@RahulNath 8 ай бұрын
Glad you enjoyed it! Do check out the full series bit.ly/asp-net-core-series
@UPSCCSE-ku7ej
@UPSCCSE-ku7ej 3 жыл бұрын
Excellent
@RahulNath
@RahulNath 3 жыл бұрын
Thank you! Cheers!
@raagasongs
@raagasongs 3 жыл бұрын
I personally learn more from your .Net core video's.. It helps to understand the fundamentals of core..
@RahulNath
@RahulNath 3 жыл бұрын
Thank you Rajesh, glad you are finding these helpful. Do let know if you need any other topics covered.
@mohammedmazin5405
@mohammedmazin5405 2 жыл бұрын
Super and clear explanatory helped me a lot. Thanks
@RahulNath
@RahulNath 2 жыл бұрын
Thank you!
@velkumars26
@velkumars26 2 жыл бұрын
Nice explanation, much informative. Good work bro
@RahulNath
@RahulNath 2 жыл бұрын
Thanks a lot Velkumar!
@UPSCCSE-ku7ej
@UPSCCSE-ku7ej 3 жыл бұрын
Awesome man ...!!
@RahulNath
@RahulNath 3 жыл бұрын
Thanks!!
@suryanarayanbaliarsingh5363
@suryanarayanbaliarsingh5363 3 жыл бұрын
Nice explanation..
@RahulNath
@RahulNath 3 жыл бұрын
Great thanks Suryanarayan. Do check out the other videos in this series kzfaq.info/sun/PL59L9XrzUa-nqfCHIKazYMFRKapPNI4sP
@ransandu
@ransandu 3 жыл бұрын
Thank you ! This helped a lot.
@RahulNath
@RahulNath 3 жыл бұрын
Thanks Ranga!
@BarbarosYurttagul
@BarbarosYurttagul Жыл бұрын
great
@RahulNath
@RahulNath Жыл бұрын
Thank you Barbaros!!
@joshmachine777
@joshmachine777 Жыл бұрын
Thanks!
@RahulNath
@RahulNath Жыл бұрын
Thank you Amit and for the super thanks !
@SantoshSingh-nw8yy
@SantoshSingh-nw8yy 2 жыл бұрын
Good one 👏
@RahulNath
@RahulNath 2 жыл бұрын
Thank you! Cheers! Hope you are liking the full series bit.ly/asp-net-core-series
@SantoshSingh-nw8yy
@SantoshSingh-nw8yy 2 жыл бұрын
@@RahulNath yep subscribed immediately 🙂
@RahulNath
@RahulNath 2 жыл бұрын
@@SantoshSingh-nw8yy 🙏
@GabrielGoncalves-ez1iv
@GabrielGoncalves-ez1iv Жыл бұрын
Thanks for this great explanation!! #aspnetoptionspattern
@RahulNath
@RahulNath Жыл бұрын
Glad it was helpful Gabriel! Hope you are enjoying the series bit.ly/asp-net-core-series
@abdullahahmed8468
@abdullahahmed8468 3 жыл бұрын
amazing man
@RahulNath
@RahulNath 3 жыл бұрын
Thank you 😀
@staker4
@staker4 3 жыл бұрын
👍
@RahulNath
@RahulNath 3 жыл бұрын
😀
@sarathbaiju6040
@sarathbaiju6040 2 жыл бұрын
Can you make a video series on SOLID principles?
@RahulNath
@RahulNath 2 жыл бұрын
Great suggestion! I will plan something.
@tubeashu
@tubeashu 3 жыл бұрын
Really liked your video, one of the best with all details. How you were able to go into CreateDefaultBuilder, is it possible in VS 2019 ?
@RahulNath
@RahulNath 3 жыл бұрын
Thank you, Ashutosh, and happy that you like them. To navigate into functions is not yet available as part of VS - There is an open ticket for that github.com/dotnet/roslyn/issues/24349 You can use the source.dot.net/ browser, but still, the Rider experience is way better. I mostly use Rider IDE in the video so that I can easily do that within the context of the app. Hope that helps.
@shreyasjejurkar1233
@shreyasjejurkar1233 3 жыл бұрын
This is quite great pattern. Nice video as always. Rahul any idea who came with up this pattern at start of .net core development?? Any insights you remember? 😁
@RahulNath
@RahulNath 3 жыл бұрын
Thanks, Shreyas, and glad you like the video. I am not sure who came up with the pattern in the first place. (Between I don't work in the .net core team - just in case you thought otherwise 😀)
@shreyasjejurkar1233
@shreyasjejurkar1233 3 жыл бұрын
@@RahulNath but you used to in past correct? When you were at MS!?
@RahulNath
@RahulNath 3 жыл бұрын
@@shreyasjejurkar1233 yeah that’s right, used to 😀
@shreyasjejurkar1233
@shreyasjejurkar1233 3 жыл бұрын
@@RahulNath ahh OK. Ok. No issues! 😇
@meayanaforever
@meayanaforever 3 жыл бұрын
Second..❤️
@RahulNath
@RahulNath 3 жыл бұрын
fourth 😂
@LencoTB
@LencoTB Жыл бұрын
Your videos are really good. I learned so much. Do you have any examples of how one would implement Options Pattern on Azure Function v4? Function apps use local.settings.json so I am missing an example how I can use the Options Pattern with the new .Net 6 Azure Functions.
@LencoTB
@LencoTB Жыл бұрын
Can't find how to use ValidateDataAnnotations for Azure Functions v4
@kalpeshblue2
@kalpeshblue2 3 жыл бұрын
first :)
@RahulNath
@RahulNath 3 жыл бұрын
third 😀
@klearner666
@klearner666 2 жыл бұрын
Can you Do this in Static class.?
@piyalibasak6886
@piyalibasak6886 Жыл бұрын
please explain a video of single tone scoped in distributed architecture
@RahulNath
@RahulNath Жыл бұрын
Can you explain a bit more on what you are looking for ? I’ve a video on Dependency Injection and lifetime scopes including Singleton in it kzfaq.info/get/bejne/j7hme86ns6jUiGg.html What specific are you looking for with distributed architecture?
@piyalibasak6886
@piyalibasak6886 Жыл бұрын
@@RahulNath I want a video where you can explain me about why we should use singletone design pattern.Generally I have seen your video of DI already.but I want to know specific real scenario where we should use single tone as well as transient and scope in .net core with real project base scenario.and if you make one video where we should use normal singletone class not specific to .net core app,in general .(I know the logic of singletone,scope and transient but I just want there use of real project based scenario from you) if you can make video on this with good information it will be really helpfull for me.
@RahulNath
@RahulNath Жыл бұрын
Thank you for your suggestion Piyali! I will add this to my list and see if I can do one soon.
@VindicatorMorty
@VindicatorMorty 3 жыл бұрын
How can i add a service with a custom created IOptions? Like services.AddScoped(options => options.Operation = "string" );
@RahulNath
@RahulNath 3 жыл бұрын
Should be possible using the Factory overrride - docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.dependencyinjection.servicecollectionserviceextensions.addscoped?view=dotnet-plat-ext-5.0&WT.mc_id=AZ-MVP-5003875 Did you get a chance to try that? Let know if you are facing any issues.
@melk48111
@melk48111 3 жыл бұрын
which editor are you using?
@RahulNath
@RahulNath 3 жыл бұрын
I am using Jetbrains Rider - www.jetbrains.com/rider/download/#section=windows You can also check out their Early Access Program which provides free access www.jetbrains.com/resources/eap/
@rohan4rich
@rohan4rich 3 жыл бұрын
What is the difference between services.AddOptions and services.ConfigureOptions ?
@RahulNath
@RahulNath 3 жыл бұрын
These two articles might help understand it a bit better - andrewlock.net/the-dangers-and-gotchas-of-using-scoped-services-when-configuring-options-in-asp-net-core/ andrewlock.net/simplifying-dependency-injection-for-iconfigureoptions-with-the-configureoptions-helper/ Let know if you have further questions and happy to do a follow up video on this.
@rohan4rich
@rohan4rich 3 жыл бұрын
@@RahulNath Thank you Rahul I will surly follow these articles.
@RahulNath
@RahulNath 3 жыл бұрын
@@rohan4rich Sure feel free to reach out in case you have more questions Rohan.
@henrrypires794
@henrrypires794 Жыл бұрын
I don't understand why do you use IOptions, what's the point of that interface?
@RahulNath
@RahulNath Жыл бұрын
It streamlines the way you can inject configuration objects into your classes, automatically refresh when values change (based on how it is set up), etc. An alternative would be custom writing all of that. What are you trying to use it for?
@henrrypires794
@henrrypires794 Жыл бұрын
@@RahulNath i was woudering why not inject the class with the configuration values and use this IOptions interface. but now i understand. Thanks
@expertreviews1112
@expertreviews1112 2 жыл бұрын
Question, can Options pattern be used to pass something other than config... what if I want to pass CustomerName to a Customer class? Can I use options pattern to pass Customer name and/or other info ?? Or maybe I want to pass a GUID to a class ??? thnx in advance
@RahulNath
@RahulNath 2 жыл бұрын
It’s not restricted to config. You could pass anything. Curious why you want to pass customer name though and how you intend to get the name . If it’s in context of request why not keep it as a function parameter ?
@expertreviews1112
@expertreviews1112 2 жыл бұрын
@@RahulNath thnx... without going into too much detail, I had a scenario where my Webhook service was receiving a token. The controller would pass this to a handler service. This handler service accepts a dependency which also requires this token to be available to all its members... I tried the options pattern but somehow couldn't make it work... Token as function parameter meant if I had 10 functions, I'd have a token arg in each of them and I wanted to avoid this...thnx in advance
@RahulNath
@RahulNath 2 жыл бұрын
@@expertreviews1112 you could have a “ContextService” injected in and have a set on it to set the token which you can call at the beginning of your handler. Easiest I can think of achieving this
@expertreviews1112
@expertreviews1112 2 жыл бұрын
@@RahulNath Interesting! Many thnx, I'll give it a shot!!
@RahulNath
@RahulNath 2 жыл бұрын
@@expertreviews1112 Do let me know how that goes 👍
How Many Balloons Does It Take To Fly?
00:18
MrBeast
Рет қаралды 91 МЛН
HAPPY BIRTHDAY @mozabrick 🎉 #cat #funny
00:36
SOFIADELMONSTRO
Рет қаралды 11 МЛН
THEY WANTED TO TAKE ALL HIS GOODIES 🍫🥤🍟😂
00:17
OKUNJATA
Рет қаралды 22 МЛН
.NET Configuration In Depth | .NET Conf 2023
29:58
dotnet
Рет қаралды 22 М.
AZURE BLOB STORAGE - Getting Started | Azure Series
30:21
Rahul Nath
Рет қаралды 4 М.
What’s the Result Type Everyone Is Using in .NET?
14:47
Nick Chapsas
Рет қаралды 104 М.
Getting Started with Event Sourcing in .NET
37:07
Nick Chapsas
Рет қаралды 51 М.
коллекционировали попрыгунчики?😭
0:59
A clash of kindness and indifference #shorts
0:17
Fabiosa Best Lifehacks
Рет қаралды 59 МЛН
В семье появился подросток!
0:15
Victoria Portfolio
Рет қаралды 3,3 МЛН
Look at two different videos 😁 @karina-kola
0:12
Andrey Grechka
Рет қаралды 9 МЛН
Они придумали бесконечные деньги
0:53
Бесполезные Новости
Рет қаралды 1,9 МЛН