Coding Tutorials
Coding Tutorials
  • 169
  • 607 984
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 czcams.com/video/_jG_RgLYijI/video.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
zhlédnutí: 1 170

Video

.NET 8 Blazor Rendering
zhlédnutí 1,3KPřed 3 měsíci
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
zhlédnutí 2KPřed 4 měsíci
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
zhlédnutí 866Před 5 měsíci
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: czcams.com/video/L6xlzZdw2As/video.html Topics include: - The TimeProvider base class - Testing time-based applications - Using FakeTimeProvider to set the ...
.NET 8 Testing Times
zhlédnutí 1KPřed 5 měsíci
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
zhlédnutí 1,3KPřed 6 měsíci
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 czcams.com/video/Sx-U6vb6CoQ/video.html - The Single Responsibility Principle czcams.com/video/IrcMr0Xqz8Q/video.html - SignalR czcams.com/video/oQ7OSX7bRto/video.html - C# 12 Primary Constructors...
C# 12 Spread Operator Performance Pitfalls
zhlédnutí 1,1KPřed 6 měsíci
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
zhlédnutí 1,7KPřed 6 měsíci
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 czcams.com/video/ez-4IaBTSso/video.html - Implementing IEnumerable czcams.com/video/3_cke_8oPhk/video.html - C# 12 Primary Constructors czcams.com/video/NFrIYZ_...
C# 12 Primary Constructors
zhlédnutí 1,4KPřed 6 měsíci
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 czcams.com/video/JDLqwxYME6M/video.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
zhlédnutí 1,2KPřed 7 měsíci
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
zhlédnutí 2,6KPřed 7 měsíci
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
zhlédnutí 2,4KPřed 8 měsíci
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
zhlédnutí 2,5KPřed 8 měsíci
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
zhlédnutí 3,4KPřed 9 měsíci
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
zhlédnutí 8KPřed 9 měsíci
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
zhlédnutí 529Před 9 měsíci
React and JWT
Blazor Authentication with JSON Web Tokens
zhlédnutí 7KPřed 10 měsíci
Blazor Authentication with JSON Web Tokens
Angular Logout
zhlédnutí 912Před 10 měsíci
Angular Logout
Angular HTTP Interceptors
zhlédnutí 4,1KPřed 11 měsíci
Angular HTTP Interceptors
Authentication Part 2 - Passing JSON Web Tokens
zhlédnutí 1,4KPřed 11 měsíci
Authentication Part 2 - Passing JSON Web Tokens
Authentication Part 1 - Individual User Accounts
zhlédnutí 4,6KPřed 11 měsíci
Authentication Part 1 - Individual User Accounts
More Swagger
zhlédnutí 734Před rokem
More Swagger
Swagger Versioning
zhlédnutí 1,8KPřed rokem
Swagger Versioning
WebAPI Versioning
zhlédnutí 1,9KPřed rokem
WebAPI Versioning
ASP.NET Integration Testing
zhlédnutí 13KPřed rokem
ASP.NET Integration Testing
ASP.NET and Swagger
zhlédnutí 2,6KPřed rokem
ASP.NET and Swagger
Blazor Pre-Rendering
zhlédnutí 3,4KPřed rokem
Blazor Pre-Rendering
C# 11 and the Scope of Checked
zhlédnutí 608Před rokem
C# 11 and the Scope of Checked
C# 11 - List Patterns
zhlédnutí 2,5KPřed rokem
C# 11 - List Patterns
C# Flags Enum
zhlédnutí 5KPřed rokem
C# Flags Enum

Komentáře

  • @MCkillcrow
    @MCkillcrow Před dnem

    Thanks - wasn't exactly what I was expecting - your example is effectively showing the mapping of output to a single Dto from multiple "dynamically" generated queries - I was hoping to see an example of Mapping to a dynamic Type which is only known at run time ... sigh

  • @KarthikChintalaOfficial

    That's the very detailed demo I haven't seen in a while on Dispose pattern and Finalize. Thank you!

  • @DimasMessias-kl4ic
    @DimasMessias-kl4ic Před 4 dny

    Where would you normally keep that JWT token? Keeping it in the session be easily found and decrypted to extract information from it. Is there a way to keep it only in memory completely invisible (using WASM)?

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo Před 4 dny

      It couldn't be decrypted, because the secret to decode it is kept on the server. Even if it could be decrypted, there's no sensitive information in there. The risk of having the JWT stolen is that it could be used to gain access to a secure server. Moreover, Session and Local storage are only available to the user of the machine, so are safe for a personal, password protected machine. On a public machine, however, they shouldn't be stored in Local storage, and the user should remember to close the browser to clear session storage. Storage in memory is safest, but least convenient.

  • @Grimlock1979
    @Grimlock1979 Před 4 dny

    The reason List doesn't provide a AsSpan() method is, if the List grows, the inner array could be a different one than the one your Span is looking at. You can still get a Span over the inner array with CollectionMarshal.AsSpan(List). It comes with a warning that no items should be added or removed while the Span is in use.

  • @natalia_sm755
    @natalia_sm755 Před 4 dny

    Is string pooling part of string interning or it's a separate mechanisms?

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo Před 4 dny

      String pooling is similar but more configurable. Interning is built in to the CLI, while pooling is part of a separate library. See learn.microsoft.com/en-us/dotnet/communitytoolkit/high-performance/stringpool

  • @anathrax6744
    @anathrax6744 Před 5 dny

    One of the best tutorials I've ever seen on a specific topic. Kudos

  • @danstoian7721
    @danstoian7721 Před 11 dny

    Awesome! thanks!

  • @hassanmohamed-iz2un
    @hassanmohamed-iz2un Před 14 dny

    The best video about delegates and events I have ever watched

  • @akeemaweda1716
    @akeemaweda1716 Před 14 dny

    Sooooo clear. Thanks a lot for this.

  • @akeemaweda1716
    @akeemaweda1716 Před 15 dny

    Many thanks for this wonderful clarification. Now I under the entire record, struct concepts.

  • @jphvnet
    @jphvnet Před 16 dny

    Finally cs gets c++ style hard to read when talking about optimized code... Nice

  • @mihailpeykov
    @mihailpeykov Před 17 dny

    All was good and informative up to the point you implement the "fast" parser using spans. That one was not good. You don't need to copy each number's characters to a stack allocated buffer just to pass them to double.Parse(Span<char>) - you could just do it with spans pointing inside the original string. That would avoid the risks of stack overflow you mentioned and will be slightly faster.

  • @foudilbenouci482
    @foudilbenouci482 Před 19 dny

    Why the 'Model' column is nullable in the database whereas the property is declared as non nullable in the Motocar class ? 10:30 thank you

  • @TWLink1
    @TWLink1 Před 20 dny

    Thank you for your clear and precise explanation. An old dog (me) learned a new trick today!

  • @marijastojanovic7414
    @marijastojanovic7414 Před 22 dny

    The explanations on this channel are excellent. Thank you!

  • @foudilbenouci482
    @foudilbenouci482 Před 22 dny

    Thank you very much.Very interesting topic

  • @mostafaessam592
    @mostafaessam592 Před 22 dny

    Awesome video ❤

  • @foudilbenouci482
    @foudilbenouci482 Před 22 dny

    The parellisation of the average() method doesn't give the same result : with parallelisation the result is 228150401,23158336 without parallelisation the method the result is 228150401,3512809.So an error is introduced

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo Před 21 dnem

      I think that's related to the rounding errors one can get with doubles. Without parallelization, the rounding error is consistent, whereas with parallelization there is a degree of randomization, but neither is correct. If you do this with decimals instead of doubles, you consistently get the result 228,150,401.25. This is because the decimal type is explicitly designed to avoid rounding errors. We can verify this is the correct result by looking at the Sum() and Count() of the results, which are: 114,075,200,625,000,000 500,000,000 Cancelling the zeros gives: 114,075,200,625 500 I'm not going to do the full long division, but it's evident this ends in exactly .25.

    • @foudilbenouci482
      @foudilbenouci482 Před 21 dnem

      @@CodingTutorialsAreGo Yes it is related the rounding errors one can get with doubles . If you chunk the list depending on the chunks and their order you wont get nécessarily the exact same result . Thank you

  • @foudilbenouci482
    @foudilbenouci482 Před 23 dny

    Parallel.ForEach(values, (value, _) => { results[value] = Factoriel(value % 20 + 1); usage.AddOrUpdate(Environment.CurrentManagedThreadId, 1, (_, count) => count + 1); } ); is working fine (value is the index) i didn't understand why you introduced the concurentBag collection for this loop

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo Před 21 dnem

      The 'results' array has to be pre-allocated to the number of results, which in this case, we happen to know. In other circumstances, we might not know the final size, and if we want the collection to expand to fit, it has to be thread safe.

    • @foudilbenouci482
      @foudilbenouci482 Před 21 dnem

      @@CodingTutorialsAreGo clear thank you

  • @llionking055
    @llionking055 Před 23 dny

    Many thanks❤ can we pass the token from the login response to the next request? We can set token to environment variable in Postman

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo Před 23 dny

      The way I'd do it would be to put the token in a variable, then use the variable in the authentication header for the request. Then you just have to cut and paste the token value from the login response to the variable.

    • @llionking055
      @llionking055 Před 21 dnem

      @@CodingTutorialsAreGo thank you for your response but I think it would be better if we could send the login request and then store it in a variable for the later request (similar to Postman)

  • @vivekmahajan6752
    @vivekmahajan6752 Před 24 dny

    Great one :)

  • @abdelazizshaban5190
    @abdelazizshaban5190 Před 25 dny

    You're underrated, Thank you

  • @foudilbenouci482
    @foudilbenouci482 Před 25 dny

    The task execution is never deferred, it is executed immediatly after being called ?! However, you can choice the place in the proogam where to wait it after being called ?! Can you tell me if i a wrong and why ? Thank you

  • @DoctorMGL
    @DoctorMGL Před 26 dny

    it can also be canceled within the for loop first line like : for (int i=0; token.IsCancellationRequested == false && i < count; i++){ ..... and i think this approach is better for performance than allowing the for() to loop > then we return it with 0 if the IsCancellationRequested success. because here we are checking for the condition before the loop even start processing

    • @CodingTutorialsAreGo
      @CodingTutorialsAreGo Před 26 dny

      Which is exactly what you don't want to do. You do not want to return 0 because that is not the correct result. And if the cancellation happened later, you would get a non-zero value that was still not the correct result. How would the client code know? You need to throw an exception to indicate that the calculation did not complete.

    • @DoctorMGL
      @DoctorMGL Před 26 dny

      ​@@CodingTutorialsAreGo , good point, thanks for bringing my attention to this , and what i actually mean depend on the case . if the user ( Cancel the task ) vs ( he EXITs the Window ) , when Existing there is no longer " telling the user where did he stop " in this case we force the Cancellation at the closest point and Dispose everything . unless you want the user to continue his task from where did he stop if he launch the ( application / task ) again . if so that's another topic related to Cashing, something you may need in applications like "Internet download manager" where you want the user to have the ability to keep downloading from the same percentage he stop at even if the application exists or crashed .

  • @abdirizakjamalismail6672

    I don't agree with making program.cs public just for integration test. you can new up a WebApplicationFactory instead of using another class which inherits it.

  • @marceloleoncaceres6826

    Great examples, thanks for sharing them,

  • @FinnGuttormsen
    @FinnGuttormsen Před 27 dny

    Following this example but using a rest api on another port, my httpClient.PostAsync first does a GET OPTIONS and then fails without ever doing the post method with a http exception "Could not fetch" . Any ideas?

  • @MuhammadAhmed-pd8zu
    @MuhammadAhmed-pd8zu Před 29 dny

    You are beyond wonderful!!!!! Thank you so much, this really helps

  • @Rohit-gq4pv
    @Rohit-gq4pv Před měsícem

    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 Před měsícem

    What if I use no secret?

  • @asesorwebvideos
    @asesorwebvideos Před měsícem

    Gracias saludos desde Chile

  • @sushantkhare8467
    @sushantkhare8467 Před měsícem

    This is a gem❤

  • @marceloleoncaceres6826
    @marceloleoncaceres6826 Před měsícem

    Thanks for the video

  • @ISKernel
    @ISKernel Před měsícem

    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 Před měsícem

    Really great video thank you!

  • @BM-jy6cb
    @BM-jy6cb Před měsícem

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

  • @agentsmith2189
    @agentsmith2189 Před měsícem

    Ty <3 !!!! greating from Venezuela

  • @johannes3980
    @johannes3980 Před měsícem

    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 Před měsícem

    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 Před měsícem

    Great Video!

  • @4rmboy666
    @4rmboy666 Před měsícem

    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 Před měsícem

    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 Před měsícem

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

  • @codingbloke
    @codingbloke Před měsícem

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

  • @conlethmackle4062
    @conlethmackle4062 Před 2 měsíci

    Such a great video

  • @conlethmackle4062
    @conlethmackle4062 Před 2 měsíci

    Best explanation yet on this topic I've seen

  • @diegomelgar2696
    @diegomelgar2696 Před 2 měsíci

    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 Před 2 měsíci

      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 Před 2 měsíci

    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 Před 2 měsíci

      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 Před 2 měsíci

      @@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 Před 2 měsíci

      @@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 Před 2 měsíci

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

  • @JohnSmith-yr7ih
    @JohnSmith-yr7ih Před 2 měsíci

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

  • @liquidpebbles
    @liquidpebbles Před 2 měsíci

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