Coding Tutorials
Coding Tutorials
  • 169
  • 593 322
Blazor RenderFragment
Writing software is all about the DRY Principle - Don't Repeat Yourself. But how can we do that in Blazor component? Enter the RenderFragment class.
Source code available at: github.com/JasperKent/Blazor-Render-Fragments
Related video: C#11 String Things ua-cam.com/video/_jG_RgLYijI/v-deo.html
Topics include:
- Creating Razor markup as strings
- The MarkupString class
- The problems of raw string literals in Razor files
- Creating literal RenderFragments
- The problem of literal RenderFragments in C# files
- General RenderFragments with lambdas
- Rendering component content in a child component
- Creating generic components
Переглядів: 860

Відео

.NET 8 Blazor Rendering
Переглядів 1,2 тис.2 місяці тому
It's a big decision: Blazor Server of Blazor WebAssembly? In .NET, you can decide on a component by component basis. Source code available at: github.com/JasperKent/Blazor-DotNet-8 Topics include: - Visual Studio Blazor Templates - Project structure - Static rendering - The [StreamRendering] attribute - Selecting the best render mode - InteractiveServer - InteractiveWebAssembly - InteractiveAut...
.NET 8 - HTTP Files
Переглядів 1,8 тис.3 місяці тому
Played-out with Postman? Sick of Swagger? Test your APIs with an HTTP file. Source code available at: github.com/JasperKent/HTTP-Files Topics include: - Using .http files in a new project. - Analysing APIs with the endpoint explorer. - Generating .http files from a Controller-based or minimal API. - Sending requests from a .http files. - Using variables in request URLs. - Using variables for th...
.NET 8 FakeTimeProvider
Переглядів 8434 місяці тому
As well as giving us TimeProvider, .NET also brings a predefined mock: FakeTimeProvider. Unfortunately, it doesn't quite work as expected. Source code available at: github.com/JasperKent/Timer-Testing Related videos: - .NET 8 Testing Times: ua-cam.com/video/L6xlzZdw2As/v-deo.html Topics include: - The TimeProvider base class - Testing time-based applications - Using FakeTimeProvider to set the ...
.NET 8 Testing Times
Переглядів 9784 місяці тому
It's always been difficult to test anything that depends on time, because time is out of control. But with the .NET 8 TimeProvider, we can take control of time itself. Source code available at: github.com/JasperKent/Timer-Testing There were a couple of imperfections in the final version on the video, which I've fixed in the latest revision on GitHub. The mocking of GetUtcNow() in TickFiresEvent...
.NET 8 Keyed Dependency Injection
Переглядів 1,3 тис.5 місяців тому
Want to dynamically switch between service implementations? In .NET 8 you can. Source code available at: github.com/JasperKent/RockPaperScissorsInjection Related videos: - C# 12 Collection Expressions ua-cam.com/video/Sx-U6vb6CoQ/v-deo.html - The Single Responsibility Principle ua-cam.com/video/IrcMr0Xqz8Q/v-deo.html - SignalR ua-cam.com/video/oQ7OSX7bRto/v-deo.html - C# 12 Primary Constructors...
C# 12 Spread Operator Performance Pitfalls
Переглядів 1 тис.5 місяців тому
Visual Studio gives us lots of hints on how to improve our code. Mostly it's right. Sometimes it's dead wrong. Source code available at: github.com/JasperKent/Spread-Benchmark Topics include: - The various ways of creating an empty array - The performance benefits of using a predefined empty array - How all ways of creating an empty string work the same way - Benchmarking of spread operator per...
C# 12 Collection Expressions and the Spread Operator
Переглядів 1,5 тис.5 місяців тому
Initializing arrays is C# has always been easier than initializing other collections. In C#12 we can do it all in the same way. Source code available at: github.com/JasperKent/Collection-Expressions Related videos: - C# 9 Fit and Finish ua-cam.com/video/ez-4IaBTSso/v-deo.html - Implementing IEnumerable ua-cam.com/video/3_cke_8oPhk/v-deo.html - C# 12 Primary Constructors ua-cam.com/video/NFrIYZ_...
C# 12 Primary Constructors
Переглядів 1,3 тис.5 місяців тому
Getting bored of having to write code in triplicate just to initialize a field? Try primary constructors. Source code available at: github.com/JasperKent/Primary-Constructors Related videos: - C#9 Records ua-cam.com/video/JDLqwxYME6M/v-deo.html Topics include: - TypeScript parameter properties - Primary constructors in records - Calling primary constructors - Primary constructors in classes and...
Entity Framework Core 8 SQL Injection Attacks
Переглядів 1,1 тис.6 місяців тому
Entity Framework has a neat feature for preventing SQL injection attacks, but it may just encourage developers to write sloppy code. Source code available at: github.com/JasperKent/.NET-8-SQL-Injection Topics include: - What is an SQL injection attack - Other problems caused by using string concatenation with SQL - String interpolation vs concatenation - Writing parameterized queries - Using LI...
ASP.NET Minimal API and Swagger
Переглядів 2,3 тис.6 місяців тому
Controllers use attributes and XML comments to provide API documentation. Minimal APIs have some alternatives. Source code available at: github.com/JasperKent/Controller-vs-Minimal-APIs Topics include: - Activating XML documentation - Adding documentation comments and attributes to static methods - The problem of comments on lambda expressions - Defining returns status codes with the fluent API...
ASP.NET Minimal API Structure
Переглядів 2,1 тис.7 місяців тому
Minimal APIs allow you to define your entire web service in Program.cs. But that's not ideal for maintainability. Here's how to structure your application. Source code available at: github.com/JasperKent/Controller-vs-Minimal-APIs Topics include: - Creating a Minimal API application - Adding GET, POST, PUT and DELETE endpoints - Injecting services - Using TypedResults - Separating endpoint func...
ASP.NET Minimal API Performance
Переглядів 2,4 тис.7 місяців тому
Minimal APIs are an alternative to controllers for developing RESTful Web Services - but where are the performance benefits? Source code available at: github.com/JasperKent/Api-Benchmarking Topics include: - Comparing the structure of Minimal APIs and controllers - Writing a simple GET endpoint - Benchmarking API calls - Comparing performance of Minimal APIs and controllers with BenchmarkDotNet...
Blazor and JWT Refresh Tokens
Переглядів 3,1 тис.8 місяців тому
We've seen how refresh tokens work on the server, but how do we send them from the browser? Source code available at: github.com/JasperKent/Blazor-Wasm-Authentication Server code available at: github.com/JasperKent/WebApi-Authentication Topics include: - Storing the refresh token - Revoking the refresh token on logout - Refreshing the JSON Web Token with the refresh token - Resending the reques...
ASP.NET and JWT Refresh Tokens
Переглядів 7 тис.8 місяців тому
Your JSON Web Token has expired. Do you have t go to the effort of entering your name and password again? Not if you have a refresh token. Source code available at: github.com/JasperKent/WebApi-Authentication Topics include: - Trading off security and convenience - Synchronizing servers with ClockSkew - Distinguishing the authentication server and the data server - Storing refresh tokens on the...
React and JWT
Переглядів 5129 місяців тому
React and JWT
Blazor Authentication with JSON Web Tokens
Переглядів 7 тис.9 місяців тому
Blazor Authentication with JSON Web Tokens
Angular Logout
Переглядів 8529 місяців тому
Angular Logout
Angular HTTP Interceptors
Переглядів 3,9 тис.10 місяців тому
Angular HTTP Interceptors
Authentication Part 2 - Passing JSON Web Tokens
Переглядів 1,3 тис.10 місяців тому
Authentication Part 2 - Passing JSON Web Tokens
Authentication Part 1 - Individual User Accounts
Переглядів 4,3 тис.10 місяців тому
Authentication Part 1 - Individual User Accounts
More Swagger
Переглядів 724Рік тому
More Swagger
Swagger Versioning
Переглядів 1,6 тис.Рік тому
Swagger Versioning
WebAPI Versioning
Переглядів 1,8 тис.Рік тому
WebAPI Versioning
ASP.NET Integration Testing
Переглядів 12 тис.Рік тому
ASP.NET Integration Testing
ASP.NET and Swagger
Переглядів 2,4 тис.Рік тому
ASP.NET and Swagger
Blazor Pre-Rendering
Переглядів 3,3 тис.Рік тому
Blazor Pre-Rendering
C# 11 and the Scope of Checked
Переглядів 602Рік тому
C# 11 and the Scope of Checked
C# 11 - List Patterns
Переглядів 2,5 тис.Рік тому
C# 11 - List Patterns
C# Flags Enum
Переглядів 5 тис.Рік тому
C# Flags Enum

КОМЕНТАРІ

  • @Rohit-gq4pv
    @Rohit-gq4pv День тому

    Just a question, what if same user logged in two different devices? For example, a user logs in first device; it will update the RefreshToken column for that user in AspNetUsers table. On device 2 login, it will update the existing RefreshToken column value(it will replace the device 1 refresh token with device 2 refresh token) .So for device 1, how will refresh token work?

  • @vladmaiorov1072
    @vladmaiorov1072 3 дні тому

    What if I use no secret?

  • @asesorwebvideos
    @asesorwebvideos 5 днів тому

    Gracias saludos desde Chile

  • @sushantkhare8467
    @sushantkhare8467 6 днів тому

    This is a gem❤

  • @marceloleoncaceres6826
    @marceloleoncaceres6826 10 днів тому

    Thanks for the video

  • @ISKernel
    @ISKernel 11 днів тому

    Very nice video !! I would love to see more. Just for clarification, it is quite difficult to follow from where "ReportThread" is called while looking at the output. Could you add maybe do something like: void ReportCall([CallerMemberName]string methodName = null, [CallerLineNumber]int lineNumber = -1) { Console.WriteLine($"Thread ID: {Thread.Id} at {methodName} line {lineNumber}"); } That would make is easier (at least for me) to follow.

  • @martinswanepoel2039
    @martinswanepoel2039 11 днів тому

    Really great video thank you!

  • @BM-jy6cb
    @BM-jy6cb 11 днів тому

    These tutorials deserve 10 times more views than they currently have. Always clear and concise with no waffle. Many thanks, Jasper!

  • @agentsmith2189
    @agentsmith2189 11 днів тому

    Ty <3 !!!! greating from Venezuela

  • @johannes3980
    @johannes3980 13 днів тому

    I have a question. When I have a MAUI app as the client, for example, what is the best practice for the refresh flow to maintain a high user experience? Because when the access token is invalid, it would take six calls until I have the data if the token needs to be refreshed. So, should the token be refreshed in the background if it’s expired to maintain a high UX? Regards

  • @jimpaloander1888
    @jimpaloander1888 20 днів тому

    1. They have to introduce vector math on arrays. Overloading operators +,*,-,/ create temporary objects. These in turn for long expressions and large vectors occupy as much extra memory as the number of extra temporaries. Fortran has it since decades ago, Zig has introduced it by scratch; it is unreasonable in 2024 C# not introducing vector math operations on arrays. 2. They should introduce a type for automatic differentiation (AD) build in the language so that 1st and 2nd order derivatives can be computed on the fly. 3. They have to introduce a feature for compile time code execution similar to Zig.

  • @johannes3980
    @johannes3980 21 день тому

    Great Video!

  • @4rmboy666
    @4rmboy666 22 дні тому

    I have a question, but the topic is a bit different from Blazor. Basically, the question is about TypedReference in .NET (when we can/should use it) and about "hidden features" in c#, specifically __arglist and __makeref (again, when we can/should use them). I've done a some research, and you don't seem to have videos on these topics (

  • @pharoah327
    @pharoah327 25 днів тому

    How can we return a Span from a function? Or any value type that has more than one field in it? In my understanding, when we return from a function, we pop the activation record, then pop the return address and follow it back to the caller. Since this pops the span from the stack, how do we use it in the calling function? With heap allocation, we can store a pointer in a register and use that to refer to the memory. Yet if we store a stack pointer to now unallocated memory, that wouldn't be good. So I'm really confused on how this would be used if returned from a function.

  • @alexulag
    @alexulag 25 днів тому

    Finally i found a video where i learned the whole concept!

  • @codingbloke
    @codingbloke 28 днів тому

    Wow! More than a year on since C#11 and I did not know about this feature. Really well explained thank you!

  • @conlethmackle4062
    @conlethmackle4062 Місяць тому

    Such a great video

  • @conlethmackle4062
    @conlethmackle4062 Місяць тому

    Best explanation yet on this topic I've seen

  • @diegomelgar2696
    @diegomelgar2696 Місяць тому

    Hi Jasper, thanks again for your high quality videos! What happens when the user refresh the page in the summary page? Will the user still fetch the summary knowing that the JWt is still valid?

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo Місяць тому

      Yes, the fetch will still work because the JWT is stored in session storage and the session persists for the lifetime of the tab. So a refresh within the tab doesn't lose the JWT.

  • @diegomelgar2696
    @diegomelgar2696 Місяць тому

    Hi Jasper, again thanks for a high quality content video!! I wonder, having the Clockskew within the gap of the Tiemespan defined in the validation parameters. Wouldn’t it be appropriate to make the refresh token endpoint protected with Authorize attribute and documenting that the refresh token endpoint must be called within X seconds/minutes of time span in order to generate a new JWT? So, instead of creating a logic for adding a column or attribute for Refresh Token in Users table, the clockskew is the key for refreshing a new JWT, thus the Authorize data annotation will do the work to validate the token. Thanks again for your videos, they are very helpful 💯

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo Місяць тому

      I've never seen that done. I'm not sure the idea of requiring the client to refresh within a time limit is a very good idea. It would require the client software to be running a timer, which obviously wouldn't work if the client shutdown (which also would lose tokens in session storage, but not local storage). Even if the client did stay up it would mean unnecessary transmission and refreshes of tokens, when the client code decided to update but the user didn't, which would be a potential security compromise.

    • @diegomelgar2696
      @diegomelgar2696 Місяць тому

      @@CodingTutorialsAreGo the scenario I am talking is exactly that. In which, the client code will pop up a modal with a timer that tells the user “hey, you have X seconds/minutes left to stay up in the session. Would you like to extend your session?” And if the timer reaches to the 0 seconds, then it would automatically logs out the user. This leads me to a second question. How to invalidate the JWT when the user logs out and the JWT is still valid? The client might erase the token from cookie or local storage but as you mentioned it could be stolen for example, a man in the middle attack. Thanks Jasper!

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo Місяць тому

      @@diegomelgar2696 That's one of the key things about JWTs - they cannot be invalidated, whereas refresh tokens can. That's why we have JWTs with a short expiry and refresh tokens with a longer one. I say they cannot be invalidated. You could make it so that the server holds a list of invalid JWTs which it rejects if they are used, but that's not the intended approach.

    • @diegomelgar2696
      @diegomelgar2696 Місяць тому

      @@CodingTutorialsAreGo nice, thank you for your time and explanation Jasper!!

  • @JohnSmith-yr7ih
    @JohnSmith-yr7ih Місяць тому

    'System.IdentityModel.Tokens.Jwt' is a legacy tool :( are you going to update WebApi+Blazor wasm Auth tutorials?

  • @liquidpebbles
    @liquidpebbles Місяць тому

    Very glad I watched this video. I didn't know about the first method presented for using render fragments. Great stuff.

  • @finwwwfinwww4669
    @finwwwfinwww4669 Місяць тому

    best explanation ....

  • @liquidpebbles
    @liquidpebbles Місяць тому

    Extremely useful feature. Thanks for bringing it to light

  • @zanagi
    @zanagi Місяць тому

    lul c# is really funny when one comes from c++ background... I was so lost.

  • @AmerBakeer
    @AmerBakeer Місяць тому

    Very useful and informative. Thank you.

  • @sadeghshooshanzadeh1382
    @sadeghshooshanzadeh1382 Місяць тому

    very very useful tutorial. tnx a lot😊

  • @ehvlullo
    @ehvlullo Місяць тому

    Great video. It's quite a big change again, but I do feel that having such granular control will be worth it in the end. I'm still trying to figure out if how much traditional web api's lose their relevance in all this.

  • @TheJessejunior
    @TheJessejunior Місяць тому

    your content is addictively good! thank you so much.

  • @TheJessejunior
    @TheJessejunior Місяць тому

    one more amazing class, explaining deep things with simplicity.

  • @Pluvo2for1
    @Pluvo2for1 Місяць тому

    I like to think of passing by reference as passing by value. Instead of passing a copy of a normal value type, we pass a copy of a memory address on the heap.

  • @Sorlandskode
    @Sorlandskode Місяць тому

    Awesome video as usuall, Jasper. I always look forward to when you release new videos.

  • @talkathiriify
    @talkathiriify Місяць тому

    Very helpful. Thank you so much.

  • @smc_onetwo
    @smc_onetwo Місяць тому

    huge help. i'll be implementing something like this. thank you

  • @4rmboy666
    @4rmboy666 Місяць тому

    Can you make a video about Covariance and Contravariance in generics or about nullable reference types in modern c#? Also thanks for videos!

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo Місяць тому

      Already done. Co/Contravariance: ua-cam.com/video/3FTvHnhmd88/v-deo.html Nullable references: ua-cam.com/video/VkelpHkkg4I/v-deo.html

    • @4rmboy666
      @4rmboy666 Місяць тому

      @@CodingTutorialsAreGo Oh i didn't see them )) Thanks a lot!

  • @CRBarchager
    @CRBarchager Місяць тому

    Very informative with great examples. I never come across this before and I've used RenderFragments combined and seperat mode for years. Thank you for sharing.

  • @JohnSmith-yr7ih
    @JohnSmith-yr7ih Місяць тому

    Hi! Thanks for viseo. can you please make a tutorial of aspNet web api + Blazor webassembly standalone app (not a `BlazorApp` or `Blazor Server` templates) Identity auth tutotial (new way, .net 8)? register, login, logout features and simple CRUD

  • @10Totti
    @10Totti Місяць тому

    Nice tutorial thanks!

  • @CodingTutorialsAreGo
    @CodingTutorialsAreGo Місяць тому

    Any other aspects of Blazor you'd like me to make a video on? Leave a comment. Source code available at: github.com/JasperKent/Blazor-Render-Fragments Remember to subscribe at ua-cam.com/channels/qWQzlUDdllnLmtgfSgYTCA.html And if you liked the video, click the 👍.

    • @robinheyer708
      @robinheyer708 Місяць тому

      Thank you very much!. It's amazing how much the understanding of one component can improve your experience in Blazor.

  • @JohnSmith-yr7ih
    @JohnSmith-yr7ih Місяць тому

    Please, can you update your minimal api tutorials to `source generators`? I've seen some articles about it but they explain so hard :(

  • @MarllonVilano
    @MarllonVilano Місяць тому

    Thanks for the videos, very good explanation and examples. One thing got my attention, the Christianity and Jewish books... Are you Christian?

  • @torrvic1156
    @torrvic1156 Місяць тому

    Thank you! Didn’t knew about TypedResults and didn’t bothered much but just returned 200 if it’s fine or something else if we have troubles.

  • @torrvic1156
    @torrvic1156 Місяць тому

    Thank you for this nice tutorial sir! Can you please tell me if we should return anything when we work with Minimal Api? I saw that people are returning Tasks and I am doing the same if we speak about Create, Delete and Update operations.

  • @jerryjeremy4038
    @jerryjeremy4038 Місяць тому

    Is this the right way to do this?

  • @ariesandhi
    @ariesandhi Місяць тому

    Dear Sir, can you make a video about JWT and using Vue.js?

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo Місяць тому

      I really don’t know Vue so I’ll have to give that one a miss.

  • @BM-jy6cb
    @BM-jy6cb Місяць тому

    Only just discovered your channel, but so glad I did. Superb teaching skills. Already subscribed. Thanks!

  • @tobiaszwojnar1465
    @tobiaszwojnar1465 Місяць тому

    your videos are amazing, yet another time only after watching your video I truly get an understanding of how sth works

  • @robinheyer708
    @robinheyer708 Місяць тому

    This is such a good use case for this feature. I believe the official documentation also uses an HTML markup string. A while ago I thought of using the raw string in Blazor to store an svg. I don't remember the reason anymore, it was probably a number of icons and I just wanted to make the HTML more readable. So I copy the whole svg markup in a raw string literal aaaand... the verbatim identifier doesn't work in Blazor (yet). You can manually escape every single quote and slash or stitch together some abomination in a custom method or using the library's markup / html methods. There is light at the end of the tunnel. Somewhere around Visual Studio 17.11 Roslyn's lexer should be leveraged in Razor which would resolve this issue.

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo Місяць тому

      Is this the sort of thing you want to do, using a RenderFragment: @page "/counter" @rendermode InteractiveAuto <PageTitle>Counter</PageTitle> <h1>Counter</h1> <p role="status">Current count: @currentCount</p> @circle <button class="btn btn-primary" @onclick="IncrementCount">Click me</button> @code { private int currentCount = 0; private RenderFragment circle =@<svg height="100" width="100" xmlns="www.w3.org/2000/svg"> <circle r="45" cx="50" cy="50" fill="red" /> </svg>; private void IncrementCount() { currentCount++; } }

    • @robinheyer708
      @robinheyer708 Місяць тому

      ​@@CodingTutorialsAreGoWell, I'll be damned... I found a GitHub issue going back years and you just got a workable solution a few hours later! Since they're SVGs I probably don't have to worry about setting up too many of these. Thanks a million, Jasper!

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo Місяць тому

      You're question inspired a new video: ua-cam.com/video/MFUW5SxbSKE/v-deo.html

  • @Yemen-Soft
    @Yemen-Soft Місяць тому

    eng\Jasper... I want to ask a question? I heard someone say that asynchronous programming does not create multiple threads, and that it only uses one thread. I see here that a new thread other than the main thread has been created, and I trust you to answer this question. My sincere regards to you.😊

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo Місяць тому

      The await and async keywords to not of themselves create threads. The await keyword is applied to a Task and waits until that Task is complete. In many cases, that Task may be running code in a separate thread, but not always. For example, if the Task caches a result, it may run in a separate thread the first time to get the data, but not subsequent times when it simply returns the cached result. It's worth noting that in JavaScript things are very different, and we don't have separate threads when using async/await.

  • @JohnSmith-yr7ih
    @JohnSmith-yr7ih 2 місяці тому

    how can i update the password or remove the account (registration)? please make a tutorial about it

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo 2 місяці тому

      I'll put it on the list.

    • @JohnSmith-yr7ih
      @JohnSmith-yr7ih 2 місяці тому

      can you please make a tutorial of aspNet web api + Blazor webassembly (not a BlazorApp or Blazor server templates) Identity auth tutotial?