dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.21k stars 9.95k forks source link

HTTP Error 500.30 - ANCM In-Process Start Failure after adding httpsredirect #18505

Closed arun1998 closed 4 years ago

arun1998 commented 4 years ago

After adding services.AddMvc(options => { options.Filters.Add(new RequireHttpsAttribute()); }) in the ConfigureServices method and var options = new RewriteOptions().AddRedirectToHttps(StatusCodes.Status301MovedPermanently); app.UseRewriter(options); in the configure method I am receiving the HTTP Error 500.30 - ANCM In-Process Start Failure

analogrelay commented 4 years ago

The 500.30 error indicates a failure launching your app (such as an exception in Startup.cs). Can you check the Windows Event Log (or "Application Events" in Azure App Service)? The exception details should be there (since they are hidden from the error page in Production environments for security reasons).

arun1998 commented 4 years ago

Hi Andrew, the log has this message - Application "application name" with physical root 'application path' failed to load clr and managed application. CLR worker thread exited prematurely. This happens only when I add the HTTPS redirect code above. Is there another way to do HTTPS redirect?

The error is thrown when the application is deployed on the TEST IIS server and no error is thrown while debugging in VS 2019

analogrelay commented 4 years ago

This happens only when I add the HTTPS redirect code above. Is there another way to do HTTPS redirect?

I doubt this is directly related to the impact. You shouldn't have to remove that functionality to fix this issue, let's try to avoid that :).

Hi Andrew, the log has this message - Application "application name" with physical root 'application path' failed to load clr and managed application. CLR worker thread exited prematurely.

Is there no other information in the log? Usually the actual exception that crashed the process will be there. Can you try the full troubleshooting steps from our docs on Troubleshooting with IIS?

arun1998 commented 4 years ago

Hi Andrew, I updated the config file to write to the logs folder. After running the app from the command prompt, this is the error in the windows application logs -

Application [applicationname] with physical root [applicaitonpath] hit unexpected managed exception, exception code = '0xe0434352'. Please check the stderr logs for more information.

However, nothing is written to the stdout file.

analogrelay commented 4 years ago

@arun1998 can you post a runnable sample project that reproduces the problem? We need to see the full context of what's going on. The error message you posted indicates that an exception is being thrown by your application at startup. Did you try the steps in the troubleshooting guide (such as running the app from the command line)?

arun1998 commented 4 years ago

Hi Andrew,

I have attached the program and start up files. I have highlighted the code which throws the error in red n the start up. Please let me know if you need more information. I really appreciate you taking the time to try and get to the bottom of this.

In the meantime, we are redirecting to https on the IIS server itself, though we would like to get this to work in code.

Thanks Startup.docx Program.docx

analogrelay commented 4 years ago

What happens when you run the app directly with dotnet on the command line (as recommended in the troubleshooting guide)? Also, the code you provided isn't sufficient to run and reproduce the issue.

ghost commented 4 years ago

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate.

See our Issue Management Policies for more information.