0

我有一个小的 Asp.Net Core Web 应用程序。我以 net461 框架为目标,因为它依赖于 Restsharp。

当我以 ./web.exe 运行此 Web 应用程序时,它返回 HTTP 500。当我从项目文件夹中使用“dotnet run”运行时,它运行良好。

我必须使用第一个版本,因为我将它发布给没有 .Net SDK 的提供商。

我能做些什么?

project.json的在这里:

{
  "dependencies": {
    //"Microsoft.NETCore.App": {
    //    "version": "1.0.0",
    //    "type": "platform"
    //  },
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "RestSharp": "105.2.3",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.Extensions.Logging.Debug": "1.0.0"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": [
        "portable-net45+win8","net451"
      ]
    }
  },

  "frameworks": {
    "net461": {}
    //"netcoreapp1.0": {
    //  "imports": [
    //    "dotnet5.6",
    //    "portable-net45+win8"
    //  ]
    //}
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimes": {
    "win81-x64": {}
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "web.config"
    ]
  },

  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}
4

1 回答 1

1

最后,我解决了这个问题。我错过了 WebhostBuilder 的一些东西。有了 .UseIISIntegration() 它可以正常工作。

于 2016-07-12T21:58:46.190 回答