我有一个MVC应用程序,在本地运行良好,但是在IIS上部署时,所有路由都返回404找不到。 在某些情况下,我的浏览器显示了布局,但没有显示该视图的数据,而是返回404。
我将向您展示一种在本地运行良好但在IIS中失败的方法。
[Route("/Customer/CustomerDetails/{id}")]
public async Task<IActionResult> CustomerDetails(int id)
{
ApiResult<eCOM_Backend.Api.Responses.Customer> apiResult = await _customerApiMethods.CustomerDetailsAsync(id);
eCOM_Backend.Api.Responses.Customer customerFromBackend = null;
if (!apiResult.HasException)
{
customerFromBackend = apiResult.Result;
}
else
{
return RedirectToAction("Error", "Error", new { reason = apiResult.Exception });
}
CustomerViewModel customer = customerFromBackend.ToCustomerViewModel();
return View(customer);
}
当我像xxx / Customer / CustomerDetails / 123这样调用此方法时,找不到页面。
我尝试了很多解决方案(修改了appsettings.json,web.config等),但到目前为止没有任何效果。
非常感谢!
答案 0 :(得分:0)
看起来像是dotnet核心。将应用程序发布到IIS时,请确保提供正确的物理路径。像inetpub\wwwroot\YourAppName
。在IIS中,右键单击您的Web应用>管理网站>高级设置,并确保物理路径结束于您的应用文件夹而不是yourApp\someOtherFolder