【问题标题】:ASP.NET application works in VS2013 but not when deployedASP.NET 应用程序在 VS2013 中有效,但在部署时无效
【发布时间】:2015-02-07 03:32:02
【问题描述】:

在部署程序后运行程序时出现以下控制台错误,而我在使用 VS2013 时没有遇到:

注意:更新了基于使用 Fiddler 的控制台错误输出(这是来自 500 状态代码的响应

readyState: 4, responseText: "<!DOCTYPE h...", status: 500, statusText: "Internal Se..."}
readyState: 4
responseText: 

"<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Error - My ASP.NET Application</title>
    <link href="/Contentbug/css?v=MDbdFKJHBa_ctS5x4He1bMV0_RjRq8jpcIAvPpKiN6U1" rel="stylesheet"/>

    <script src="/bundles/modernizr?v=wBEWDufH_8Md-Pbioxomt90vm6tJN2Pyy9u9zHtWsPo1"></script>


</head>
<body>


    <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="/">Application name</a>
            </div>
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li><a href="/">Home</a></li>
                    <li><a href="/Home/About">About</a></li>
                    <li><a href="/Home/Contact">Contact</a></li>
                </ul>
                    <ul class="nav navbar-nav navbar-right">
        <li><a href="/Account/Register" id="registerLink">Register</a></li>
        <li><a href="/Account/Login" id="loginLink">Log in</a></li>
    </ul>

            </div>
        </div>
    </div>
    <div class="container body-content">



<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>


        <hr />
        <footer>
            <p>&copy; 2015 - My ASP.NET Application</p>
        </footer>
    </div>

    <script src="/bundles/jquery?v=FVs3ACwOLIVInrAl5sdzR2jrCDmVOWFbZMY6g6Q0ulE1"></script>

    <script src="/bundles/bootstrap?v=2Fz3B0iizV2NnnamQFrx-NbYJNTFeBJ2GM05SilbtQU1"></script>



    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModal-label" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModal-label">ATTENTION: Please Review Your Custom Email Before Sending</h4>
                </div>
                <div class="modal-body">
                    ...
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Edit</button>
                    <button type="button" class="btn btn-primary" id="sendButton" data-dismiss="modal">Send</button>
                </div>
            </div>
        </div>
    </div>



    <script>
    $('[name="optradio1"]').on('change', function () {
    ....
    });
    </script>

    ...

</body>

</html>
status: 500
statusText: "Internal Server Error"

在阅读了一些关于 BundleConfig 的帖子后,我对其进行了更改,以便我的包名称与我的目录名称之一不同,但这仍然不起作用,因为我遇到了同样的错误,除了更新改名。

想法/建议?

BundleConfig

public class BundleConfig
{
    // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.validate*"));

        // Use the development version of Modernizr to develop with and learn from. Then, when you're
        // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-*"));

        bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                  "~/Scripts/bootstrap.js",
                  "~/Scripts/respond.js"));

        bundles.Add(new StyleBundle("~/Contentbug/css").Include(
                  "~/Content/bootstrap.css",
                  "~/Content/site.css"));
    }
}

_layout.cshtml 部分

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - My ASP.NET Application</title>
    @Styles.Render("~/Contentbug/css")
    @Scripts.Render("~/bundles/modernizr")

</head>

【问题讨论】:

    标签: asp.net-mvc twitter-bootstrap visual-studio-2013 error-handling bundling-and-minification


    【解决方案1】:

    首先做这些事情。

    1. 仅部署已编译的代码。
    2. 托管目录应该是根目录(例如:www.stackoverflow.com),您不应该托管在子目录中(例如:www.stackoverflow.com/supraj)。
    3. 确保您通过 FileZilla 进行托管,这是一种安全的方法。

    如果这些都不起作用,如果你在 localhost 中成功运行,那么唯一的问题是 webconfig 文件

    【讨论】:

    • 我通过 azure 托管(例如 supraj.azurewebsites.net)——#2 和 #3 是否仍然适用?另外,我有点不确定如何仅部署已编译的代码——通过 VS2013 部署网站的默认设置是什么?目前使用“Web Deploy”发布方式,我的配置设置为“Release”
    • 构建后按照以下步骤操作:1.转到->构建->发布,(在本地目录中发布)然后您的代码被编译并发布到您在发布时选择的目录中,2.下载filezilla-> filezilla-project.org 3.host 通过 filezilla 到 azure(你可能需要 url、用户名、密码,你将在 azure 中发布 *** 文件)
    • 编译后的代码不能通过VS2013部署有什么原因吗?因为我不确定为什么 asp.net 不允许工作解决方案。如果我们假设问题出在 webconfig 上,我应该解决什么问题?
    猜你喜欢
    • 2020-10-07
    • 1970-01-01
    • 1970-01-01
    • 2017-06-25
    • 1970-01-01
    • 2017-08-31
    • 2018-12-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多