I have successfully ran locally the code over IIS and localhost.
However, after publishing as a self contained app to my web server (running windows server 2019), I get the following error;
An error occurred while starting the application. TypeLoadException: Could not load type 'System.Web.IHttpModule' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Unknown location
TypeLoadException: Could not load type 'System.Web.Util.RequestValidationSource' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Unknown location
ReflectionTypeLoadException: Unable to load one or more of the requested types. Could not load type 'System.Web.IHttpModule' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Could not load type 'System.Web.Util.RequestValidationSource' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
Loader Exceptions: Could not load type 'System.Web.IHttpModule' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Could not load type 'System.Web.Util.RequestValidationSource' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. TypeLoadException: Could not load type 'System.Web.IHttpModule' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Can anyone shed any light on why this occurs please?
Enable error log into webconfig and check log for issue .
or try below code into web.config to see the actual error <aspNetCore .....> <environmentVariables> <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" /> </environmentVariables> </aspNetCore>