Just a friendly reminder to myself (and for whom it may concern): This error message tends to appear when the ASP.NET API can’t talk to the IdentityServer.
Especially tricky when using an ASP.NET API and IdentityServer4 behind a reverse proxy (like nginx). The external world might be able to talk to the IdentityServer, but the API server / container might need some additional configuration with the internal host:port of the IdentityServer.
If I want to display a PDF file in the browser instead of downloading a copy, I can tell the browser via an additional Content-Disposition response header.
This code example assumes that the file content is available as byte-array, reading the content from a database, for example.
// Get action method that tries to show a PDF file in the browser (inline)
public ActionResult ShowPdfInBrowser()
byte pdfContent = CodeThatRetrievesMyFilesContent();
if (pdfContent == null)
var contentDispositionHeader = new System.Net.Mime.ContentDisposition
Inline = true,
FileName = "someFilename.pdf"
return File(pdfContent, System.Net.Mime.MediaTypeNames.Application.Pdf);
Please keep in mind that ultimately we don’t have control over the browser. We can politely request to show the PDF inline, but this can be overridden by a user configuration, for example.
A video tutorial based on my learnings of ASP.NET MVC 5, ASP.NET Identity, SQL Server and Azure.
Summary: I will show you how to create a very simple web application with user authentication. Users can register, log in, create diary entries (text) and visualize their entries.
In part one we will create, test and refactor the application locally on our computer. Although the app is very simple we will touch a lot of different technologies. You will also see some issues you may experience when starting with ASP.NET MVC in Visual Studio and how to fix them.
In part two we will publish our app to the cloud (Azure). Please subscribe to get notified when part two is finished.
ASP.NET Identity ApplicationUser and ApplicationDbContext overview
ASP.NET Identity tables
Extend DiaryEntry model class for usage in DbContext
Create foreign key property and navigation properties (Entity Framework)
Add new DiaryEntry table to DbContext
Create new model class from viewmodel
Use Entity Framework to insert into DiaryEntries table
Show result of data-model change: “Server Error in Application. The model backing the ‘ApplicationDbContext” context has changed since the database was created. Consider using Code First Migrations to update the database”