ASP.NET Core 2.0网站POST请求在Azure上导致404 [英] ASP.NET Core 2.0 site POST request resulting in 404 on Azure

查看:110
本文介绍了ASP.NET Core 2.0网站POST请求在Azure上导致404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将ASP.NET Core 1.1 Web应用程序升级到2.0,并在本地进行了无问题测试.但是,当将该站点部署到Azure时,在本地工作的POST请求会产生404(我想对于所有POST请求都可能是相同的,但是由于这个问题,我无法登录).

I've just upgraded an ASP.NET Core 1.1 web application to 2.0 and tested without issue locally. However, when the site is deployed to Azure a POST request that worked locally results in a 404 (I guess this could be the same for all POST requests, but I'm unable to log-in due to the issue).

有什么想法为什么在部署到Azure时可能无法正常工作,而在本地通过IIS Express运行时却能正常工作?

Any ideas why this might fail to be working when deployed to Azure but working perfectly when run through IIS Express locally?

我删除了Azure上的原始部署插槽,并重新创建为最初在该插槽上进行部署,将旧的1.1 DLL与较新的2.0 DLL混合在一起,使站点完全无法正常工作.

I deleted the original deployment slot on Azure and re-created as initially deploying over the slot mixed old 1.1 DLL's with the newer 2.0 DLL's and prevented the site working at all.

推荐答案

似乎我被我的Web应用程序对错误的处理不力所吸引.我假设Startup.cs中的app.UseExceptionHandler("/Error")(默认情况下,我的HomeController不需要/Home/Error开头的Home)会重定向到错误页面,但对我来说不是.

Seems I was caught out by poor handling of errors by my web application. I'd assumed that app.UseExceptionHandler("/Error") (I default my HomeController to not require the leading "Home" for /Home/Error) in Startup.cs would redirect to an error page, but for me it is not.

我的根本问题是数据库连接错误,该错误导致POST控制器方法失败.响应返回了404而不是错误状态,我被困住了.

My underlying issue was a database connection error that caused the POST controller method to fail. I was caught out by the response returning a 404 rather than an error status.

我将需要详细研究ASP.NET Core的错误处理方式.

I will need to investigate how error handling works in more detail for ASP.NET Core it seems.

这篇关于ASP.NET Core 2.0网站POST请求在Azure上导致404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆