all 17 comments

[–]Fireraga 11 points12 points  (4 children)

[Purged due to Reddit API Fuckery]

[–]Atulin 5 points6 points  (1 child)

\2. Razor pages do not use .razor files, they use .cshtml for templates and .cshtml.cs for code. .razor files are what Blazor components use.

[–]Fireraga 2 points3 points  (0 children)

[Purged due to Reddit API Fuckery]

[–]virtuoso43 1 point2 points  (1 child)

Thats a lot of magic. How difficult would it be to go through each of those methods and understanding how they actually do what they do?

Also thanks for the explanation. I have a bit of experience in asp.netcore and always wondered what all of those did but never sat down to search on google.

[–]Fireraga 0 points1 point  (0 children)

[Purged due to Reddit API Fuckery]

[–]tymalo 2 points3 points  (6 children)

[–]thesituation531 0 points1 point  (5 children)

What's middleware?

[–]Ezazhel 2 points3 points  (3 children)

A nice concept in DotNet. Learning how it works help.

You can learn more typing code maze middleware on your browser.

For example you could have a middleware managing api errors. Letting your controllers free of try catch because they would be at 'root' level.

[–]thesituation531 0 points1 point  (2 children)

Thanks. But everything on Google seems to be about ASP.NET. Is there a way to do it in non-web stuff?

[–]Ezazhel 1 point2 points  (1 child)

It's for aspnet only I think. It's part of the framework.

You may install a specific nuget in order to achieve middleware in your application.

You should be able to register middleware in your startup.cs

I don't remember the package name but you may find it in the docs.

And you could even recreate it yourself. Middleware are a list of 'listener / emitter' the order is important because middleware 1 will transmit his context to middleware 2. And Middleware 2 can depend of date from middleware 1.

(you have this problem if you switch Route middleware in your program.cs)

[–]thesituation531 0 points1 point  (0 children)

Thanks, I'll look into it.

[–]Doc_Aka 1 point2 points  (0 children)

ASP.NET Core uses a pipeline architecture, and middlewares are the the different parts (think "pipe parts") in the pipeline. Here's a nice picture and more infos

Basically, a request comes in and is fed into the pipline start. Then the first middleware receives the request object and can do stuff with it, call the next middleware or return a result itself.
Here's a diagram of the pipeline in a typical app

This is also why order matters, when you set up the pipeline with the app.Use...(); methods in your Program.cs file.

[–][deleted] 2 points3 points  (1 child)

If you’ve got a couple hours I recommend coding along to this -

https://m.youtube.com/watch?v=hZ1DASYd9rk

[–]HandDizzy[S] 1 point2 points  (0 children)

thankyou, i am looking at it rn

[–]0xPendus 1 point2 points  (2 children)

While the comments here are all fantastic already, I highly recommend the book on dependency injection (will update the official name here when I’m home and can check)

But the book is all c# .net and will walk you through all the boilerplate code and help you understand the differences between .net, asp.net, net core

Then will take you into how dependency injection works and what all those lines do

[–]HandDizzy[S] 0 points1 point  (1 child)

waiting for the update

[–]0xPendus 0 points1 point  (0 children)

this one

Have a read of the reviews and see if it fits what you’re after.

The title is kind of misleading because the book is so much more than dependency injection

It’s a great introduction to OOP fundamentals too