VideoOnDemand22
This repository contains the code to the book ASP.NET Core 2.2 MVC, Razor Pages, API, JSON Web Tokens & HttpClient
There have been some issues with the package references in the Common and Database projects that are fixed.
To run the downloaded or cloned code, do this:
- Update to Visual studio 2019 (16.5.0), or install it here: https://visualstudio.microsoft.com/downloads/
- Install the latest SDK for ASP.NET Core 2.2 (2.2.8) here: https://dotnet.microsoft.com/download/dotnet-core/2.2
- When the installation is complete, download or clone the code in this repository.
- Open the solution in VS 2019.
- Run the update-database command in the Package Manager Console to create an empty database.
- Open the Startup.cs file in the VOD.UI project.
- Uncomment the following line of code in the Configure method: DbInitializer.Initialize(db);
- Save all changes.
- Close Visul Studio 2019 and reopen it (in some cases there might be an issue with IIS if you don't restart.)
- Start the applicaiton. (This should add data to the database because you uncommented the code in the Configure method)
- Stop the application and comment out the code you uncommented in the Configure method (step 7).
- Start the application again and log in as the Admin user.
How to create a new admin user after the database has been seeded with data.
- Register a new user with the site.
- Open the SQL Server Explorer in Visual Studio 2019.
- View the data in the AspNetUsers table.
- Copy the user id from the user you created.
- Open the AspNetUserRoles table.
- Add a USER-ROLE combination for the id 1 (which is the admin role in the AspNetRoles table) and the user id you copied earlier.
- Logout any user and restart the application if the browser is running the applicaiton.
- You can now login as the new user as an admin.