ASP.NET应用程序在VS2013中工作,但在部署时不工作

时间:2015-02-07 03:32:02

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

在部署程序后运行程序时出现以下控制台错误,这是我在使用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>

1 个答案:

答案 0 :(得分:1)

首先做这些事情。

  1. 仅部署已编译的代码。
  2. 托管目录应该是根目录(例如:www.stackoverflow.com),您不应该在子目录中托管(例如:www.stackoverflow.com/supraj)。
  3. 确保通过FileZilla托管,这是一种安全的方法。
  4. 如果这些不起作用,如果你成功运行在localhost中,那么唯一的问题是webconfig文件