<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: dyagzy</title>
    <description>The latest articles on DEV Community by dyagzy (@dyagzy).</description>
    <link>https://dev.to/dyagzy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F290984%2F3112c13b-832c-400c-a889-6887bb6e5706.jpg</url>
      <title>DEV Community: dyagzy</title>
      <link>https://dev.to/dyagzy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dyagzy"/>
    <language>en</language>
    <item>
      <title>How to Create Photo/Image Gallery Using C# Asp.Net Core 5 Mvc, Cloudinary  and Auth0 Api</title>
      <dc:creator>dyagzy</dc:creator>
      <pubDate>Sat, 16 Oct 2021 09:52:22 +0000</pubDate>
      <link>https://dev.to/hackmamba/endsars-photoimage-gallery-using-c-aspnet-core-5-mvc-cloudinary-and-auth0-api-4acb</link>
      <guid>https://dev.to/hackmamba/endsars-photoimage-gallery-using-c-aspnet-core-5-mvc-cloudinary-and-auth0-api-4acb</guid>
      <description>&lt;p&gt;&lt;strong&gt;Table of Content&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;Required Tools Needed&lt;/li&gt;
&lt;li&gt;Setting Up

&lt;ul&gt;
&lt;li&gt;Cloudinary Account&lt;/li&gt;
&lt;li&gt;Visual Studio&lt;/li&gt;
&lt;li&gt;Auth0 Account&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Coding Proper&lt;/li&gt;

&lt;li&gt;Test One&lt;/li&gt;

&lt;li&gt;Adding Cloudinary Credentials to the  Project&lt;/li&gt;

&lt;li&gt;Test Two&lt;/li&gt;

&lt;li&gt;Test Three&lt;/li&gt;

&lt;li&gt;Test Four&lt;/li&gt;

&lt;li&gt;Cloudinary Check&lt;/li&gt;

&lt;li&gt;Adding Auth0 to the Project&lt;/li&gt;

&lt;li&gt;Test Five&lt;/li&gt;

&lt;li&gt;The End&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;We are going to build an image or photo gallery using Cloudinary Api as the remote image server, Auth0 for authentication with C# Asp.Net Core as the backend technology. This project is aimed at providing a working tool for human right activist by automating image upload process as they embark on their work in difficult and hazard situations. The users of this tutorial must have some proficiency in C# technology.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Required Tools  We Need&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sign up with Cloudinary&lt;/li&gt;
&lt;li&gt;Get Visual Studio 2019&lt;/li&gt;
&lt;li&gt;Sign up with Auth0&lt;/li&gt;
&lt;li&gt;Note pad&lt;/li&gt;
&lt;li&gt;Sql server&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Setting Up&lt;/strong&gt;&lt;br&gt;
Cloudinary Account&lt;/p&gt;

&lt;p&gt;The first thing to do is to sign up on Cloudinary here &lt;a href="https://cloudinary.com/documentation/cloudinary_get_started" rel="noopener noreferrer"&gt;https://cloudinary.com/documentation/cloudinary_get_started&lt;/a&gt; so that we can get access to the required Api for image upload.&lt;br&gt;
Upon successful sign up, the following are automatically generated for you:&lt;br&gt;
Cloud name:&lt;br&gt;
API Key:&lt;br&gt;
API Secret:&lt;br&gt;
API Environment variable:&lt;/p&gt;

&lt;p&gt;So click on the account settings section to see what your Api key, Cloud name and Api secret are. Copy out this values and keep it in your notepad.&lt;br&gt;
Since we intend to use Cloudinary within a DotNet application, we will rely heavily on this Cloudinary documentation for DotNet &lt;a href="https://cloudinary.com/documentation/dotnet_integration" rel="noopener noreferrer"&gt;https://cloudinary.com/documentation/dotnet_integration&lt;/a&gt;.&lt;br&gt;
At this moment, this would be all for Cloudinary. Next we set up our coding environment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting Up&lt;/strong&gt;&lt;br&gt;
Visual Studio&lt;br&gt;
The IDE for this project is visual studio 2019, so open your browser and go to &lt;a href="https://visualstudio.microsoft.com/downloads/" rel="noopener noreferrer"&gt;https://visualstudio.microsoft.com/downloads/&lt;/a&gt; click on Visual studio 2019  and download the community version.&lt;br&gt;
Installation and set up procedure for the visual studio 2019 can be found here &lt;a href="https://www.tektutorialshub.com/visual-studio/how-to-download-and-install-visual-studio-2019/" rel="noopener noreferrer"&gt;https://www.tektutorialshub.com/visual-studio/how-to-download-and-install-visual-studio-2019/&lt;/a&gt;&lt;br&gt;
Launch the newly installed app and select create a project and select Asp.Net Core Web Application Net 5 as the version. Lets call the name of this project  ImageGallery.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmh4jrcze73ymq04d969g.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmh4jrcze73ymq04d969g.jpeg" alt="new projectScaffold test"&gt;&lt;/a&gt;&lt;br&gt;
Fig 1.0&lt;br&gt;
Run the project to ensure everything is fine.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2gnnwgmrvmat6f9n3jk1.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2gnnwgmrvmat6f9n3jk1.jpeg" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Fig 1.1&lt;br&gt;
You should see a web browser fired up automatically similar to this shown below:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbq7u527hkt7fgb8ivnaz.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbq7u527hkt7fgb8ivnaz.jpeg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig 1.2&lt;br&gt;
Go to the Url section of this page above and now copy the text written there. This should be similar to this  &lt;a href="https://localhost:44375/" rel="noopener noreferrer"&gt;https://localhost:44375/&lt;/a&gt; . This value will be our call back Url which will be used much later in the project. For now just save it inside your notepad:&lt;br&gt;
&lt;strong&gt;Setting Up&lt;/strong&gt;&lt;br&gt;
Auth0 Account&lt;/p&gt;

&lt;p&gt;If you don’t already have an account with Auth0, the first thing you have to do us is to sign up for    free by using this link &lt;a href="https://auth0.com/" rel="noopener noreferrer"&gt;https://auth0.com/&lt;/a&gt; click the sign up button to sign up and follow the prompts.&lt;br&gt;
Choose a Region where you want the app to be hosted then click the Create account button.&lt;br&gt;
Next click on the link written “Create Application” it is similar to the figure below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdyin28g02xw4ssrzz6gj.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdyin28g02xw4ssrzz6gj.jpeg" alt="Auth0 setup"&gt;&lt;/a&gt;&lt;br&gt;
Fig 1.3&lt;br&gt;
The Auth0 service will ask that you supply the following values such as :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Name:  This is asking you to fill in the name of your DotNet application&lt;/li&gt;
&lt;li&gt;Application Type:  Select the type of application you want to build&lt;/li&gt;
&lt;li&gt;What Technology are using to build your project :Select Asp.Net Core v3&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A client Id number will be automatically generated for you, copy this and paste it inside the notepad.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgqytk3aw34gh718sp43c.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgqytk3aw34gh718sp43c.jpeg" alt="Auth0 setup 2"&gt;&lt;/a&gt;&lt;br&gt;
Fig 1.4&lt;/p&gt;

&lt;p&gt;Next you have to make Auth0 to be aware of your Asp.Net app, by clicking the Settings button in the figure above.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8vbpmub3fgria2wdtwrg.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8vbpmub3fgria2wdtwrg.jpeg" alt="Auth0 setup 3"&gt;&lt;/a&gt;&lt;br&gt;
Fig 1.5&lt;/p&gt;

&lt;p&gt;Copy and paste the following parameters Name, Domain, Client Id, Client secret which were automatically generated for you into the notepad document above.&lt;br&gt;
Scroll down to the Application Url section of the settings, copy the call back Url from the notepad  and paste this into the “Allowed Call Back Url” box and then attach  /callback at the end of the text.&lt;br&gt;
Next we also copy and past the call back Url into the “Allowed Logout Url”&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F06kibe69kie23zp9c4ql.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F06kibe69kie23zp9c4ql.jpeg" alt="Auth0 setup 4"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig 1.6&lt;br&gt;
Let’s quickly have a snap shot of what we have in our notepad file&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Falw5sjk2t1751s8iwto9.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Falw5sjk2t1751s8iwto9.jpeg" alt="Notepad cross section"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig 2.0&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Coding Proper&lt;/strong&gt;&lt;br&gt;
We will return now to the visual studio and start proper coding for the project.&lt;br&gt;
Right click on the solution file and click add new project. This will take you to the same screen where we selected the type of Asp.Net core template that we chose initially.&lt;br&gt;
Go to the search box and type class library and select Class Library (.Net Core), name this SimpleImageGallery.Data&lt;br&gt;
We need one more class library so repeat the process a second time but this time around, we will call the name of this class library SimpleImageGallery.Services. &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh6cejvaxctlwx26x2hc0.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh6cejvaxctlwx26x2hc0.jpeg" alt="Project arrangement"&gt;&lt;/a&gt;&lt;br&gt;
Fig 2.1&lt;br&gt;
We will refer to SimpleImageGallery.Data as the Data layer. This layer will handle all data access issues such as entity model classes, database class , Migration files etc.&lt;br&gt;
We will refer to SimpleImageGallery.Services as the Service layer. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Project  Referencing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now we need to make the three separate projects above communicate with each other.&lt;br&gt;
Starting from the ImageGallery project, click on dependencies, add SimpleImageGallery.Data and  SimpleImageGallery.Services respectively as dependencies.&lt;br&gt;
Now move to the  SimpleImageGallery.Services project add SimpleImageGallery.Data as a dependencies.&lt;br&gt;
Now right click the data layer and add a folder, name this folder Models,  add a class, to the Models folder name this class GalleryImage.cs&lt;br&gt;
&lt;strong&gt;Entity Models&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;We add another entity class Image tag&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Right click on the web ImageGallery project and select ManageNugget package.&lt;br&gt;
add Microsoft.EntityFrameworkCore.Design as dependency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Database Context&lt;/strong&gt;&lt;br&gt;
Next we need to add the Database context class lets call this class SimpleImageGalleryDbContext.&lt;br&gt;
The SimpleImageGalleryDbContext will represent our data access class i.e. the class via which we can talk to the database.&lt;br&gt;
Add the following nuggets packages as dependencies.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg6w47l9s1tz4jliu71u2.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg6w47l9s1tz4jliu71u2.jpeg" alt="nuggets packages"&gt;&lt;/a&gt;&lt;br&gt;
Fig 2.2&lt;br&gt;
We will add three different packages below to the data access layer one after following the process above.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;MicrosoftEntityFrameworkCore (5.0.10)&lt;/li&gt;
&lt;li&gt;MicrosoftEntityFrameworkCore.SqlServer (5.01.0)&lt;/li&gt;
&lt;li&gt;MicrosoftEntityFrameworkCore.Tools (5.01.0)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Add DbSet properties to the SimpleImageGalleryDbContext  and initialize it with the code as written below.&lt;br&gt;
 See the snippet below:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
&lt;strong&gt;Migrations&lt;/strong&gt;&lt;br&gt;
Return to the ImageGallery project i.e., the web project and open up the appsettings.json file&lt;br&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fblua4mrkr4eudc2wmgte.jpeg" alt="appsettings 1"&gt;

&lt;p&gt;Fig 2.3&lt;br&gt;
We need to add connection strings to the appsettings.json file&lt;br&gt;
Just before the "AllowedHosts": "*" add the your connection strings.&lt;br&gt;
 &lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Now we have to register the Sql server in the StartUp class. &lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Now we are all set to run our migration&lt;br&gt;
 Select Package manager console and type the command below Add-Migration firstMigration press the enter key.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fljy9tdv8ii7r82c6kay1.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fljy9tdv8ii7r82c6kay1.jpeg" alt="migration cmd"&gt;&lt;/a&gt;&lt;br&gt;
Fig 2.5&lt;br&gt;
Next enter this second command Update-Database at the PM&amp;gt; prompt and press enter.&lt;br&gt;
 Open your Sql server to confirm that your new database has been created there.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5331l1uwvrtjmzf7rnzz.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5331l1uwvrtjmzf7rnzz.jpeg" alt="database cross section"&gt;&lt;/a&gt;&lt;br&gt;
Fig 2.6&lt;br&gt;
Now lets go over to the Web app project (ImageGallery) open it and add a class to the models folder there. Lets call this class UploadImageModel&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
Next we will add another class to the models folder and name it GalleryIndexModel. The GalleryIndexModel will have two properties as shown below.


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Next we will add another class to the models folder and name it GalleryDetailModel. The GalleryDetailModel will have five properties as shown below.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Interface  Declarations&lt;/strong&gt;&lt;br&gt;
Right click on the Data layer project and click add a class name it IImageService.&lt;br&gt;
Copy the following codes into this interface class&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Head over to the Service layer, add a new class which will implement the IImageService.&lt;br&gt;
Create a constructor of the ImageService class and then inject an instance of  the SimpleImageGalleryDbConetx class.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyw9o3y59mutr34fuy5hu.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyw9o3y59mutr34fuy5hu.jpeg" alt="constructor injection"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig 3.0&lt;br&gt;
Copy the codes below as shown below&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The GetWithTag is similar to the GetById method except that it returns the images alongside the tag description of each images.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Views&lt;/strong&gt;&lt;br&gt;
Return to the web project , right click on the Views folder and add another folder name it Gallery.&lt;br&gt;
Add a file to the folder call name it Index.cshtml&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn1z7e1pqn1b1j3pc4tju.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn1z7e1pqn1b1j3pc4tju.jpeg" alt="empty views file"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig 3.1&lt;/p&gt;

&lt;p&gt;Delete all the text in fig 3.1 replace with the codes below.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Also, right click on the Views folder and add another folder name it Image then add a new view file call it  UploadImage.cshtml&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn1z7e1pqn1b1j3pc4tju.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn1z7e1pqn1b1j3pc4tju.jpeg" alt="empty views file"&gt;&lt;/a&gt;&lt;br&gt;
Fig 3.2&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;The code above basically helps to create a form with a minimalist styling  for presenting an image on the  browser. &lt;br&gt;
&lt;strong&gt;Controller&lt;/strong&gt;&lt;br&gt;
Add a new controller to the controller’s folder name it GalleryController. Inject the Image service as a constructor injection into this controller&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjk2wg0ptcayvrm0oozac.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjk2wg0ptcayvrm0oozac.jpeg" alt="controller injection"&gt;&lt;/a&gt;&lt;br&gt;
  Fig 3.3&lt;br&gt;
Next we write the Http action method and name it Index&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;CSS Styling&lt;/strong&gt;&lt;br&gt;
Open the wwwroot folder in the web project, click the CSS folder and  double click on the site.css file to open it.&lt;br&gt;
This file already contains the basic CSS styling that is used to render the default Asp.Net core Mvc page when the project is run, we will only modify this file to accommodates the changes that we want to see whenever the Upload.cshtml file is rendered on the browser.&lt;br&gt;
Add this code below to the site.css file&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Add Upload Button&lt;/strong&gt;&lt;br&gt;
Next we need to add an upload button to the navigation bar so that we can begin to upload images to the database&lt;br&gt;
To do this, open the _Layout.cshtml file located in the Shared folder. When this file is opened, it already contains some default codes used for rendering the layout.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F132xd8q846rtj9xd224d.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F132xd8q846rtj9xd224d.jpeg" alt="default codes"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig 3.4&lt;br&gt;
Identify the portion of the _Layout.cshtml that has the code similar to the one below then delete&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
Paste this code below to replace the code you had just deleted above&lt;br&gt;
 &lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Lastly, before we test our application, go to the Startup class and lets modify the Mvc route.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmg85e3qdk6mzzk361h2m.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmg85e3qdk6mzzk361h2m.jpeg" alt="add routing"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig 3.5&lt;br&gt;
Locate the  app.UseEndPoints method and it should look like what is above.&lt;br&gt;
 &lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Register Interface Service&lt;/strong&gt;&lt;br&gt;
Now we need to register the IImage interface class in the StartUp class by adding the snippet below.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;Test One&lt;/strong&gt;&lt;br&gt;
Run the app, you should see a web browser similar to this below&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp6oydbdw07hg26vlr20m.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp6oydbdw07hg26vlr20m.jpeg" alt="added upload button"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig 3.6&lt;br&gt;
If you have a similar web browser as shown above then you should congratulate yourself, else, try to go over the steps above a second time so as to trace where you missed out.&lt;br&gt;
Now you can see the Upload button has been  successfully added but when the Upload button is clicked, we get a 404 page not found error, so lets  fix this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Image Upload Service&lt;/strong&gt;&lt;br&gt;
To be able to use the  Cloudinary service in our project, we need to have an interface that will hold the implementation of how we want this Cloudinary Api to function within our application. So return back to the Web project, right click to add a folder name it Infrastructures.&lt;br&gt;
Add an interface class to the Infrastructures name it ICloudinaryImageUpload.cs. Inside this interface class add the code snippet below.&lt;/p&gt;

&lt;p&gt;Task UploadPicture(UploadImageModel model);&lt;/p&gt;

&lt;p&gt;Add another class to the Infrastructures folder name it CloudinaryImageUpload.cs. This class has  to implement the ICloudinaryImageUpload interface &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqzuf7i0j4yq2ei1ei2ia.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqzuf7i0j4yq2ei1ei2ia.jpeg" alt="cloudinary class"&gt;&lt;/a&gt;&lt;br&gt;
 Fig 4.0&lt;br&gt;
 &lt;strong&gt;Adding Cloudinary Credentials to the  Project&lt;/strong&gt;&lt;br&gt;
Now we need to add the Cloudinary Api credentials that we got upon sign up into our project. We can hide this in the appsettings.json file. Now open the appsettings.json file and add the following code snippets as a json object.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F60olvycfmcpeaep0o6v2.jpeg" alt="appsettingCloudinary"&gt;

&lt;p&gt;Fig 4.1&lt;br&gt;
  Go to the CloudinaryImageUpload class and add the Cloudinary credentials to this class as a private properties&lt;br&gt;
 &lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
Right click on the web project and add the nugget package for Cloudinary add Cloudinary.DotNet as a dependency.

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh152mggsm7770p0dsqoz.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh152mggsm7770p0dsqoz.jpeg" alt="Image Cloudinary sdk"&gt;&lt;/a&gt;&lt;br&gt;
  Fig 4.2&lt;br&gt;
Next we initialize all the private properties of the Cloudinary Api credentials  as shown below.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Now lets write the logic that will expose our application to the remote Cloudinary service &lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;We will write a small private function to handle passing in tags  when uploading images for us and then call it in the method above see code snippet below&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
We are done setting up the logic that will expose our application to the Cloudinary Api in the remote server.&lt;br&gt;
Create a constructor of the ImageController and inject the ICloudinaryImageUpload interface service.

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F97q97mtgd7l9bqhk8byd.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F97q97mtgd7l9bqhk8byd.jpeg" alt="ImageController"&gt;&lt;/a&gt;&lt;br&gt;
  &lt;/p&gt;
&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
We are done setting up the logic that will expose our application to the Cloudinary Api in the remote server.&lt;br&gt;
Create a constructor of the ImageController and inject the ICloudinaryImageUpload interface service.

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_130D4051B20D7BD1D4482FD2BC142C23536ED27B806A3AC41882727210A27051_1632931700719_ImageController.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fpaper-attachments.dropbox.com%2Fs_130D4051B20D7BD1D4482FD2BC142C23536ED27B806A3AC41882727210A27051_1632931700719_ImageController.JPG"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig 4.3&lt;br&gt;
 Inside this controller class, we need two methods, the first will handle a Get Http action while the second will handle the POST Http action respectively.&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;
&lt;br&gt;
So lets quickly talk through what is happening here.&lt;br&gt;
Lastly, we return a redirect to action response which basically is to take the user back to the home page where he or she could see the newly uploaded image.&lt;br&gt;
We are all set and ready to run a second test of our application to see how far we are doing or not.

&lt;p&gt;&lt;strong&gt;Test Two&lt;/strong&gt;&lt;br&gt;
Run the application and click on the Upload button, you should see this exception shown in fig 4.4 below.&lt;/p&gt;

&lt;p&gt;See the figure below&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fid3jjji7ri5vw525g0cw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fid3jjji7ri5vw525g0cw.jpeg" alt="exception page"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig 4.4&lt;/p&gt;

&lt;p&gt;What the exception is saying is that we need to register the ICloudinaryImageUpload in the configure method of the StartUp class.&lt;br&gt;
Now go to the configure method of the StartUp class and register the above Interface as a Scooped service  using the codes snippet below:&lt;br&gt;
services.AddScoped();&lt;/p&gt;

&lt;p&gt;Your code should look like the image below&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdrnbwwqi4zqzwmx7e4je.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdrnbwwqi4zqzwmx7e4je.jpeg" alt="StartUp class"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig 4.5&lt;br&gt;
 &lt;strong&gt;Test Three&lt;/strong&gt;&lt;br&gt;
Now we are ready to  test our application again to see how we are doing.&lt;br&gt;
Run the application and then click the Upload button.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc0jbs278z99mq3whwuq9.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc0jbs278z99mq3whwuq9.jpeg" alt="Image upload viewPage"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig 4.6&lt;br&gt;
 Fill in the  boxes, choose any image from your local machine and then click submit.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxucliq2axnfolp29rgl8.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxucliq2axnfolp29rgl8.jpeg" alt="EndSars Aisha"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig 5.0&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Four&lt;/strong&gt;&lt;br&gt;
For test four, we simply want to confirm that our uploaded images are stored up in the Cloudinary server and also on our local database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Local DataBase Check&lt;/strong&gt;&lt;br&gt;
So lets check the database first,&lt;br&gt;
Launch your Sql database, navigate to your database and open the GalleryImages table to check&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiqxba1xxzlpv2kd5yent.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiqxba1xxzlpv2kd5yent.jpeg" alt="database 2"&gt;&lt;/a&gt;&lt;br&gt;
  Fig 5.1&lt;/p&gt;

&lt;p&gt;Just pay attention to the  Url of the last two images, we can see the Url path to the images we uploaded to the Cloudinary server  sitting right there on our local database. You can copy this Url and past it into your browser to see the exact image.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cloudinary Check&lt;/strong&gt;&lt;br&gt;
Next login into your Cloudinary account on the browser, click the Media Library button and you should see  the uploaded image here.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw5nxobfwzwxauxizi4m2.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw5nxobfwzwxauxizi4m2.jpeg" alt="Image cloudinary 3"&gt;&lt;/a&gt;&lt;br&gt;
   Fig 5.2&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxucliq2axnfolp29rgl8.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxucliq2axnfolp29rgl8.jpeg" alt="EndSars Aisha"&gt;&lt;/a&gt;&lt;br&gt;
Fig 5.3&lt;/p&gt;

&lt;p&gt;At this point we are 85% done with our project.&lt;br&gt;
Now  we need to configure authentication.&lt;br&gt;
&lt;strong&gt;Adding Auth0 to the Project&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We will use the  Auth0 authentication Api, which we have already signed up for at the beginning of this tutorial or you click here&lt;br&gt;
The first thing we have to do is to add the Auth0 credentials i.e. Domain, ClientId, ClientSecret to the appsettings.json file&lt;br&gt;
See the figure below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjb9n5owp0yf0tpvwa1av.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjb9n5owp0yf0tpvwa1av.jpeg" alt="Auth0 cred"&gt;&lt;/a&gt;&lt;br&gt;
  Fig 5.4&lt;/p&gt;

&lt;p&gt;The next thing we will do is to go to the Web project and add the necessary nugget packages we need in other to be able to use theAuth0 authentication Api.&lt;br&gt;
Go to the manage Nugget manager window and type this&lt;br&gt;
Microsoft.Asp.NetCore.Authentication.OpenIdConnect, then install it.&lt;br&gt;
Then we will follow the Auth0 DotNet documentation &lt;br&gt;
&lt;a href="https://auth0.com/docs/quickstart/webapp/aspnet-core" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq1sbv9k9rhvnzq2bqvky.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq1sbv9k9rhvnzq2bqvky.jpeg" alt="AddScopped"&gt;&lt;/a&gt;&lt;br&gt;
  Fig 5.5&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Click &lt;a href="https://auth0.com/docs/quickstart/webapp/aspnet-core/01-login#configure-your-application-to-use-auth0" rel="noopener noreferrer"&gt;here&lt;/a&gt; to learn more&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Five&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Launch the application again and click on Login button.&lt;br&gt;
 It should take you to the Auth0 login page see below.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ce0rmjdnuep6ll1qem7.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ce0rmjdnuep6ll1qem7.jpeg" alt="Auth0 login"&gt;&lt;/a&gt;&lt;br&gt;
Fig 5.6&lt;br&gt;
 Provide your username and password that you had used to sign up on Auth0 then click on Continue.&lt;/p&gt;

&lt;p&gt;At this point we are sure that our application is working well.&lt;br&gt;
 But at the moment when a user clicks on the Upload button , the user is able to upload images immediately without login in into our application. This is not supposed to be so. The ideal situation is such that a user must login first before he or she could be allowed to upload an image.&lt;/p&gt;

&lt;p&gt;To fix this, we return back to the ImageController and then add the Authorize attribute on the Upload action method see Fig 6.0 below.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhza6sp6l54jxtvmut01j.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhza6sp6l54jxtvmut01j.jpeg" alt="Authorize Annotation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fig 6.0&lt;br&gt;
Test the application again by clicking on the Upload button and then the application should immediately direct you to the Auth0 login page as above.&lt;/p&gt;

&lt;p&gt;This is the end of this tutorial.&lt;/p&gt;

&lt;p&gt;Please drop me comments, questions, let me know about what you are building with what you have learnt.&lt;br&gt;
The entire code can be found &lt;a href="https://github.com/dyagzy/EndSars-Image-Album/tree/master" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;br&gt;
Thank you for your time.&lt;br&gt;
Content created for the &lt;a href="https://content.hackmamba.io/" rel="noopener noreferrer"&gt; Hackmamba &lt;/a&gt; Jamstack Content Hackathon using &lt;a href="https://auth0.com/" rel="noopener noreferrer"&gt; Auth0 &lt;/a&gt;and &lt;a href="https://cloudinary.com/" rel="noopener noreferrer"&gt; Cloudinary&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
