Upgrading to .NET Core: From WebAPI to ASP.NET Core API - A TimCo Retail Manager video

preview_player
Показать описание
Next up in the .NET Core upgrade is our WebAPI. We will upgrade our API to .NET Core 3.0. Part of this process will include using the new dependency injection system. We will also replace our dependencies and work through authentication.

One-off tutorials are awesome but they aren't the only thing you should be doing to learn C#. Another vital part of learning is learning how to put it all together. This interactive course is all about putting the pieces together. You can watch each video on its own or you can watch them in order and see a bigger picture. The choice is yours.

This course focuses on real-world development. As such, we are simulating that we work for TimCo Enterprise Solutions on a brand new product, the TimCo Retail Manager. Just like in the real world, we are starting out with one set of requirements but know that over time they will change.
Рекомендации по теме
Комментарии
Автор

Don't have the words to express how much I love you work.

quentincouissinier
Автор

Another amazing episode. Thanks @IAmTimCorey for being awesome!

byjindu
Автор

Now I'm getting in somewhat familiar terrirory again, feels much relaxing to follow along now.

Stoney_Eagle
Автор

Hi Tim. Really nice tutorial.
Will need this very soon. Thanks

milankroupa
Автор

for anyone using password with different validation (I use one char password since this is a tutorial)


first, for the back-end logic, you need to go to Startup.cs > ConfigureServices method and in the options =>...)" add the password options like here




for the front-end, the views have their own validation as well, but the viewmodels need to be scaffolded (like it says in the video at 12:25)



do as above and select Register, SetPassword (ChangePassword and ResetPassword in case you want to use them later from the razor pages)

Now expand folders the scaffolded pages can be expanded (have an arrow next to the plus sign) and *.cshtml.cs is shown; there you can clearly see where you need to edit the minimum password length


Hope this helps

alexandrunuta
Автор

Thanks Tim for your tutorials. I come across the "An error occurred while sending the request". I don't think I missed any step but will see it I get it solved with the next tutorials :-)

ludovicwagner
Автор

Hi Tim i'm having a little problem about the new Api project and any kind of help would be greatly appreciated. I have this 'No connection could be made because the target machine actively refused it' error when i start the app. i tried to change the base address Uri in App.config in my Wpf UI which the new API uses (localhost:44300) but still got the error, and i tried to put a breakpoint on the base address from the ApiHelper which i hard coded the Uri of which the new Api uses, but it still doesn't change the previous uri (localhost:44321). Im stuck here trying all the possible solutions and i can't move forward, what should i do? Thank you.

orisit
Автор

He tim amazing tutorial as always, can we expect one about Xamarin soon ?

pylvr
Автор

The new project options keep changing in Visual Studio. Now 18 months later I didn't have the same project type so I used the one that seemed to be similar (ASP .NET Core Web App) but I didn't get any controllers, just pages. Adding folders for the Controllers and Models wasn't difficult and creating the new classes was the same. It all worked in the end. I got confused when the default roles needed to be created because I had no HomeController. I added it to the privacy.cshtml.cs file and that works also. So for everyone having the same problem, this is an option.

erikvolger
Автор

Hi,
My kestrel console doesn't log any info except the few lines when starting the app


I tried changing the logging level to diagnostic,
added Logging to services in startup.cs,
added logging configuration in Program.cs > CreateDefaultBuilder,
added console template in appsettings.json,

but nothing worked, the kestrel console didn't log anything (info or error).


Did I miss something in the video?


Thank you

alexandrunuta
Автор

I recommend implementing those over rides, first it's the only way to make a model that nherits from ApplicationUser (If you wanted add to the default model)
Also those pages still work when they are in the DLL; and Most are active. Don't like the idea of active pages responding without them being in the project.

JohnPeter-yfjf
Автор

Hi Tim,
Thank you for these amazing series.
I have three questions though:
1. You mentioned from the start of this project that you are not a big fan of EF, I am not a fan of it as well as I like to have full control of the connection to the DB. But you used it in the WebAPI part for Identity. I've searched the web for a way to use Identity and bypass EF. I did find some complex solutions for that by creating ApplicationUser (inherits from IdentityUser) and ApplicationRole (inherits from IdentityRole) models, and create UserStore and RoleStore classes that implements some interfaces in order to load and save data to the DB. Do you have a simple way of doing so or you recommend using EF for Identity?
2. Instead of having two databases, why don't we merge them into one DB?
3. Instead of having the register/login actions in the same WebAPI project, why not moving them out into the UI project?

Best regards

Amer

ameral-mahdawi
Автор

Copying and pasting to new files is fine for a project with 5 controllers. But, migrating a production project this way is going to take a long time.

pilotboba
Автор

Adding roles like that (45:10) could be an excellent opportunity to show how a seed migration can be done.

First you have to override the ApplicationDBContext like that:
protected override void OnModelCreating(ModelBuilder builder)
{



new IdentityRole
{
Id = Guid.NewGuid().ToString(),
Name = "Admin"
},
new IdentityRole
{
Id = Guid.NewGuid().ToString(),
Name = "Cashier"
},
new IdentityRole
{
Id = Guid.NewGuid().ToString(),
Name = "Manager"
}
);
}
Then, go to the Package Manager Console, type Add-Migration SeedRoleData.
Then type Update-Database
And voila, the role data is in a database already.

Freeliner
Автор

Thanks for the video Tim . really like always very cool . just a question what about C# Data Access course i thought it will be released at the end of Okt.

abdallabenomran
Автор

Great video, love your teachings, clear and awesome.
I had a question Tim. I came upon a class with a constructor with this keyword in it. I looked it up and seems classes can have this keyword in constructor but I fail to see why you would use this, it isn't clear to me. Maybe one day I will see an answer in one of your videos?

Guacamole
Автор

Hi Tim. Probably a silly question, but swagger does not work on this version. Is that expected?

LarryB
Автор

Thank you for the great video. I do have a question regarding authentication. In this video, when you create ASP.NET Core project, you choose "Web Application" and for Authentication you choose "Individual User Accounts" then EF will create some ASpNetxxx tables in SQL Server for Authentication. Is there any other way for authentication if I don't want to use EF at all in the project? I want to fully use Dapper only. Do you have any video about that?

sovannseung
Автор

Hi Tim, did you ever had issues with the default developer ssl certificate for ASP.NET Core on Windows? I have certificate trusted (via dotnet dev-certs https --trust), chrome still see the site as "Not Secure" and in WPF at the end of this video I don't have "Not Found" but error: "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel." and then inner error: "The remote certificate is invalid according to the validation procedure."... No idea if this is in app and will be fixed later, or really an issue on my system.

StefanJarina
Автор

Hi Tim. Have an issue have been chasing for awhile, when logging in this "string userId = is returning a null userId.(endpoint on Core API) Any idea why this might occur. Seems I am getting a token when logging in, but this is null.

rykeeconsulting
visit shbcf.ru