During the upgrade of an old project from netcore2.2 to 3.1, an Ocelot gateway interface program changes the project file
- <TargetFramework>netcoreapp2.2</TargetFramework>
+ <TargetFramework>netcoreapp3.1</TargetFramework>
Replace the Services.Addmvc() in your project:
services.AddMvc(options => { options.EnableEndpointRouting = false; });
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
The method Configure(IApplicationBuilder app, IWebHostEnvironment env) retains the original app.UseMvc();
The compiler passed, but the runtime page reported an error: HTTP Error 500.37 – ANCM Failed to Start Within Startup Time, searched the web for a solution and gave a way to modify the startupTimeLimit value.
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<location>
<system.webServer>
<aspNetCore xdt:Transform="SetAttributes(startupTimeLimit)" startupTimeLimit="300">
</aspNetCore>
</system.webServer>
</location>
</configuration>
The run result page is directly inaccessible.
Solution:
You only need to add a project node
< AspNetCoreHostingModel> OutOfProcess OK.
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
</PropertyGroup>
After doing the above, the project runs normally. In addition, the above services.AddMvc() is not the recommended solution.
AddMvc(); comment out app.UseMvc() in the Configure method; then add the following code.
//app.UseMvc();
app.UseRouting();//add
app.UseEndpoints(endpoints =>//add
{
endpoints.MapControllers();
});
Read More:
- [Solved] HTTP Error 405.0-Method Not Allowed occurs in the Put operation of the REST service on IIS7.5
- IIS Web Deploy Website Error: HTTP error 500.19 – Internal Server Error
- How to Solve Error: Cannot find the declaration of element ‘beans’.
- [Solved] Asp.Net Core IIS Error: HTTP Error 500.30 – ASP.NET Core app failed to start
- [Solved] Synchronous operations are disallowed. Call ReadAsync or set AllowSynchronousIO to true instead.
- How to Fix win10 video dxgkrnl fatal error
- [Solved] Git Push Error: &fatal: the remote end hung up unexpectedly
- [Solved] The method getContextPath() from the type HttpServletRequest refers to the missing type String
- How to Fix Spoolsv.exe Application Error
- [Nginx] Configure nginx to support websocket to solve the problem of returning 400 error
- [Solved] Error in porting libzrtp: automake-1.14: command not found
- Android Error:Internal error:org.gradle.tooling.BuildException: Could not execute build…
- Git Push Error: Proxy CONNECT aborted [How to Solve]
- [Solved] Spring cloud introduces zuul dependency error
- [Solved] Git Clone Error: error setting certificate verify locations
- How to Solve Error: libproxychains4.So error
- How to Solve Error: Type mismatch: cannot convert from Object to Car
- Xcode12.5 package framework error [How to Solve]
- [Solved] SpringMVC Error: element web-app must be declared