部署到godaddy后MVC内部资源错误

时间:2016-09-19 11:57:23

标签: asp.net-mvc asp.net-web-api

我已将我的MVC网站部署到GoDaddy,当我尝试加载它时,我得到以下内容: -

500 - 内部服务器错误。 您正在查找的资源存在问题,无法显示。

我已尝试过网络配置中的详细配置

<configuration>
    <system.webServer>
        <httpErrors errorMode="Detailed" />
        <asp scriptErrorSentToBrowser="true"/>
    </system.webServer>
    <system.web>
        <customErrors mode="Off"/>
        <compilation debug="true"/>
    </system.web>
</configuration>

我还确保我的项目的.NET框架与托管版本

相同

我确保所有相关的dll都设置为复制local = true

我甚至将以下Application_Error方法添加到我的global.asax中,但它没有做任何事情

    protected void Application_Error()
    {
        HttpContext ctx = HttpContext.Current;
        KeyValuePair<string, object> error = new KeyValuePair<string, object>("ErrorMessage", ctx.Server.GetLastError().ToString());
        ctx.Response.Clear();
        RequestContext rc = ((MvcHandler)ctx.CurrentHandler).RequestContext;
        string controllerName = rc.RouteData.GetRequiredString("controller");
        IControllerFactory factory = ControllerBuilder.Current.GetControllerFactory();
        IController controller = factory.CreateController(rc, controllerName);
        ControllerContext cc = new ControllerContext(rc, (ControllerBase)controller);

        ViewResult viewResult = new ViewResult { ViewName = "Error" };
        viewResult.ViewData.Add(error);
        viewResult.ExecuteResult(cc);
        ctx.Server.ClearError();
    }

我可以从我的托管帐户访问任何日志吗?

缺乏想法 - 任何建议都非常感激

1 个答案:

答案 0 :(得分:0)

我发现如果我只把它放在我的网络配置中

<configuration>
    <system.webServer>
        <httpErrors errorMode="Detailed" />
    </system.webServer>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>

我得到了一个更好的错误信息,这是一个让我悲痛的安全级别。我最后需要添加

<trust level="Full" /> 

在我的web.config文件的system.web部分