Even though all my projects are in .NET Core now, I rarely get the opportunity to use Identity because of my work with our backend Legacy system. Recently, though, I built a very lightweight SEO Management system for one of our sites (that allows a 3rd party to tweak our page titles, meta tags, etc) and wanted to give them user access and roles.
The entire project can be found on GitHub, but below is just a running list of sites I used to get this done, noting all the troubleshooting and stupid little mistakes I did along the way.
Adding Identity to an Already Existing Project
This part was relatively easy and the Microsoft documents provided an easy enough guide. I believe I had some issues:
CS1902 C# Invalid option for /debug; must be full or pdbonly – with the Data Migrations because I didn’t have EntityFramework installed. Basically, all errors in this phase were not as presented – they were mostly because I was lacking packages to migrate.
To ensure I had all the right packages installed, i used: Microsoft.AspNetCore.App -Version 2.2.6
Also, in this area, I decided not to put the connection string in appsettings.json, opting …
The API mentioned in my first tutorial got taken down and so I had to do some updates. First, choose another 3rd party API. I currently am trying out HTML 2 PDF Rocket and modified my code a bit:
public async Task<FileStreamResult> PrintAsync(int id)
InvoiceVM invoiceVM = new InvoiceVM();
invoiceVM = invoiceRepository.Get(id);
var engine = new RazorLightEngineBuilder()
.UseFilesystemProject(_hostingEnvironment.WebRootPath + "\\pdf\\")
var view = await engine.CompileRenderAsync("PDF.cshtml", invoiceVM);
string apiKey = "xxxxxxxxxxxxxxxxxxxx";
using (var client = new WebClient())
// Build the conversion options
NameValueCollection options = new NameValueCollection();
MemoryStream ms = new MemoryStream(client.UploadValues("http://api.html2pdfrocket.com/pdf", options));
return new FileStreamResult(ms, "application/pdf");
This is based directly off the HTML 2 Rocket documentation. For the rest of the code see the first tutorial.
I had a recent bug that took me much too long to solve and the root of the cause was me. I got a bit too delete happy and deleted a crucial file that allows me to use Razor Tag Helpers to bring a List into a View as a Drop Down (Select).
Here’s how the error presented itself:
- SelectList won’t populate
- Select or DropDown is empty
- value = Microsoft.AspNetCore.Mvc.Rendering.SelectList or
- System.Linq.OrderedEnumerable2 [Microsoft.AspNetCore.Mvc.Rendering.SelectListItem, System.String]