Reputation: 2690
I am building and testing a aspnet core app using SSL. Running the site in IIS Express works fine. So, I thought I might see what's required to get it running on IIS 10. As expected, there are a few issues.
First off, I need to clarify that I have successfully hosted a non SSL aspnet app in IIS, so all the bits needed for an aspnet core app are there. But in the case of a SSL app, all I get is a message in the browser saying that an error occurred. Also nothing useful in the webserver logs.
So, my first test was to try and run the app directly in the published folder using dotnet xxx.dll. That's when I noticed the authorization error.
services.Configure<MvcOptions>(options =>
{
options.Filters.Add(new RequireHttpsAttribute());
});
Upvotes: 2
Views: 4298
Reputation: 2690
I solved the issue by generating a pfx certificate as explained on Shawn Wildermuth's blog (https://wildermuth.com/2016/10/26/Testing-SSL-in-ASP-NET-Core). Once this is done, modify your Program.cs file as follows:
Once this is done,re publish your project (command: dotnet publish)and move the pfx file into the published folder.
Now, when you run dotnet MyFileName.dll in the published folder, it can access the cert and everything works. ( Well it did for me )
Upvotes: 1