亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么我只在紅隼上得到 500?

為什么我只在紅隼上得到 500?

C#
撒科打諢 2022-11-22 15:10:28
我有一個ASP.NET Core 2.0 WEB-API,它應該可以在kestrel上運行,因為它將在那里托管。當我開始使用 Kestrel(查看下面的 launchSettings)時,有一個 POST,我總是得到500 返回,而無需進入代碼。意味著我到處都留下了斷點,當我在 Swagger 中執行 POST 時,沒有斷點被擊中。當我改用 IIS 時,它工作正常。500 馬上就來了。500 也是在 Linux Kestrel 上部署后出現的。我實現@Startup.cs:    public void Configure(IApplicationBuilder app, IHostingEnvironment env)    {        app.Use((context, next) =>        {            context.Response.Headers.Remove("Server");            return next();        });@程序.cs:    public static IWebHost BuildWebHost(string[] args) =>        WebHost.CreateDefaultBuilder(args)            .UseStartup<Startup>()            .UseUrls("http://0.0.0.0:5000")            .UseIISIntegration()            .UseApplicationInsights()            .UseKestrel()            .Build();@launchSettings.json:"Kestrel": {  "commandName": "Project",  "launchBrowser": true,  "launchUrl": "",  "environmentVariables": {    "ASPNETCORE_ENVIRONMENT": "Development"  }}使用 Kestrel,POST 調用應該使用與 IIS 相同的所有邏輯來處理 Controller 方法。
查看完整描述

1 回答

?
慕的地10843

TA貢獻1785條經驗 獲得超8個贊

我得到它的工作


    public static IWebHost BuildWebHost(string[] args) =>

        WebHost.CreateDefaultBuilder(args)

            .UseStartup<Startup>()

            .UseIISIntegration()

            .UseApplicationInsights()

            .UseKestrel(options =>

            {

                options.Listen(IPAddress.Parse("0.0.0.0"), 5000);

            })

            .Build();

和啟動設置:


    "CZKestrel": {

  "commandName": "Project",

  "launchBrowser": true,

  "environmentVariables": {

    "ASPNETCORE_ENVIRONMENT": "Development"

  },

  "applicationUrl": "http://localhost:59883/"

}

用于本地調試。


為了讓它作為服務工作,我做了 dotnet restore 和 dotnet build,我只將帶有創建的 dll 的文件夾復制到另一個地方,而不是運行/啟動服務。我想當我啟動它時,我應該在里面或 dll 文件夾上面的一個文件夾?,F在可以了。


查看完整回答
反對 回復 2022-11-22
  • 1 回答
  • 0 關注
  • 96 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號