我将.NET Core 2.0安装到了我的Windows Server 2008上,我的有两个Web项目。它们在我的电脑上都可以工作。但是当我将其中一个发布到服务器时,一个项目可以正常工作而另一个项目会出现以下错误:
HTTP错误502.5 - 进程失败
应用程序'MACHINE/WEBROOT/APPHOST/KI-TAP.COM'的实际根目录为'C:\HostingSpaces\Reseller1\ki-tap.com\wwwroot\',无法通过命令行'dotnet .\ki-tap.dll'启动进程,错误代码为'0x80004005 : 8000808c。
我已经更新了我的 Windows Server,但它仍然显示相同的错误。
这是我的program.cs文件(我没有在此处添加代码。这是默认值)。
HTTP错误502.5 - 进程失败
应用程序'MACHINE/WEBROOT/APPHOST/KI-TAP.COM'的实际根目录为'C:\HostingSpaces\Reseller1\ki-tap.com\wwwroot\',无法通过命令行'dotnet .\ki-tap.dll'启动进程,错误代码为'0x80004005 : 8000808c。
我已经更新了我的 Windows Server,但它仍然显示相同的错误。
这是我的program.cs文件(我没有在此处添加代码。这是默认值)。
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
这里是我的web.config
文件(已发布和默认代码):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\ki-tap.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
以下是我的startup.cs文件(我添加了会话配置):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace ki_tap
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddSession();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseSession();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
}
}
编辑:
在@set的建议下,我在Windows Server 2008的cmd控制台中运行了以下命令:
C:\Program Files (x86)\dotnet\dotnet myProjectPath\project.DLL
结果出现以下错误。我该怎么办?
package: 'Microsoft.AspNetCore.Antiforgery', version: '2.0.1'
path: 'lib/netstandard2.0/Microsoft.AspNetCore.Antiforgery.dll'
his assembly was expected to be in the local runtime store as the application
s published using the following target manifest files:
aspnetcore-store-2.0.3.xml