500 - 在 ASP.NET MVC 应用程序中发布重定向后出现内部服务器错误

问题描述 投票:0回答:1

我对具有新 URL 的页面进行了以下重定向:

[RoutePrefix("eventos-online")]
public class OnlineEventsController : Controller
{
    [Route]
    public ActionResult Index()
    {
        return View();
    }

    [Route("contacto")]
    public ActionResult Contact()
    {
         return Redirect(Url.Action("Index", "OnlineEvents") + "#contacte-nos");
    }
}

在我的笔记本电脑(

localhost
)上,发布到生产环境后一切正常 - https://www.izigo.pt/eventos-online/contacto - 我得到:

500 - 内部服务器错误。
您要找的资源有问题,无法显示。

编辑:发现问题,应用程序的 IIS 主文件夹中的“contacto”文件夹中有一个带有重定向的 Web.config 文件。删除文件夹,问题解决。

c# asp.net-mvc redirect
1个回答
0
投票

经过深入搜索,我在 Web 应用程序 IIS 文件夹的“contacto”文件夹中找到了一个 Web.config 文件,其中包含重定向:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpRedirect enabled="true" destination="https://www.izigo.pt/eventos-online#contacte-nos" exactDestination="true" childOnly="true" httpResponseStatus="Permanent" />
    </system.webServer>
</configuration>

删除文件夹后,问题解决。

这里奇怪的事情是,将路由重命名为 [Route("contactos")] 在生产服务器中运行良好,这就是我开始朝这个方向搜索的原因。

© www.soinside.com 2019 - 2024. All rights reserved.