C# 浏览到在本地主机上正常运行的网页时出错500

C# 浏览到在本地主机上正常运行的网页时出错500,c#,sql-server,asp.net-mvc,razor,C#,Sql Server,Asp.net Mvc,Razor,我在调试部署到IIS的MVC ASP.NET网页时遇到了可怕的问题。该网站在制作该网站的PC机上的localhost上运行良好。但是,当我在同一网络上的另一台电脑上导航到该页面时,会出现以下错误: Fiddler2的进一步检查为我提供了以下信息,这是我从该解决方案中获得的唯一调试信息: 以下是Layout.cshtml: <!DOCTYPE html> <html lang="en"> <head> <meta charset

我在调试部署到IIS的MVC ASP.NET网页时遇到了可怕的问题。该网站在制作该网站的PC机上的localhost上运行良好。但是,当我在同一网络上的另一台电脑上导航到该页面时,会出现以下错误:

Fiddler2的进一步检查为我提供了以下信息,这是我从该解决方案中获得的唯一调试信息:

以下是Layout.cshtml:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>@ViewBag.Title - Intranet Page</title>
        <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
        <meta name="viewport" content="width=device-width" />
        @Styles.Render("~/Content/css")
        @Scripts.Render("~/bundles/modernizr")
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/Scripts/application.js" type="text/javascript" charset="utf-8"></script>
    </head>
    <body>
        <header>
            <div class="content-wrapper">
                <div class="float-left">
                    <p class="site-title">@Html.ActionLink("IntranetPage", "Index", "Home")</p>
                </div>
                <div class="float-right">
                 <!--   <section id="login">
                    </div>
                    <div id="logindisplay">
                        Context.User.Identity.Name <strong>@Context.User.Identity.Name</strong>!
                    </section>  This works correctly to get DOMAIN/USERNAME-->
                </div>
            </div>
        </header>
        <div id="body">
            @RenderSection("featured", required: false)
            <section class="content-wrapper main-content clear-fix">
                @RenderBody()
            </section>
        </div>
        @Scripts.Render("~/bundles/jquery")
        @RenderSection("scripts", required: false)
    </body>
</html>

@ViewBag.Title-内部网页面
@style.Render(“~/Content/css”)
@Scripts.Render(“~/bundles/modernizer”)

@Html.ActionLink(“内部网页”、“索引”、“主页”)

@渲染部分(“特色”,必填项:false) @RenderBody() @Scripts.Render(“~/bundles/jquery”) @RenderSection(“脚本”,必需:false)
以及有关的索引页:

@model IEnumerable<WhoIs.Models.Employee>
@{
    ViewBag.Title = "Contoso Employees";
}
@section featured {
    <section class="featured">
        <div class="content-wrapper">
            <hgroup class="title">
                <h1>@ViewBag.Title.</h1>
            </hgroup>
        </div>
    </section>
}

      <label for="filter">Enter employee details here : </label>
      <input type="text" name="filter" value="" id="filter" />

<h2><strong>Users</strong> (<a href="/home/create" style="color: blue;">create new</a>)</h2>
<br />

<div style="min-height: 150px; font-size: 1.25em">
    <div style="margin-bottom: .5em">
        <table><thead><tr><th>Name</th><th>Branch</th><th>Phone No.</th><th>Username</th><th>Email</th></tr></thead>
            <tbody>
            @foreach ( var prod in Model )
                {
                    <tr>
                        <td>@prod.FullName</td> 
                        <td>@prod.Branch</td> 
                        <td>@prod.PhoneNo</td> 
                        <td>@prod.DomainAC</td> 
                        <td>@prod.Email</td> 
                        @if (User.IsInRole(@"Admins") || User.Identity.Name == prod.DomainAC) {
                                <td><a href="/home/edit/@prod.Id"  style="color: blue;">edit</a></td>
                         }else{
                         <td>User => @User.ToString()</td>   
                        }
                    </tr>
                 }
                 </tbody>
            </table>
        </div>
     </div>
@model IEnumerable
@{
ViewBag.Title=“Contoso员工”;
}
@特色栏目{
@ViewBag.Title。
}
在此处输入员工详细信息:
用户()

NameBranchPhone No.UsernameEmail @foreach(模型中的var prod) { @产品全名 @生产部门 @生产电话号码 @prod.DomainAC @生产电子邮件 @if(User.IsInRole(@“Admins”)| | User.Identity.Name==prod.DomainAC){ }否则{ User=>@User.ToString() } }
这将呈现一个简单的页面,其中包含Contoso的员工列表,使管理员和用户自己能够编辑他们的详细信息。有人能看到是什么导致我的问题吗?我对此进行了彻底调查,但没有结果

我已将一个.edmx文件添加到链接到远程数据库的“模型”文件夹中。我已尝试编辑web.config,通过添加以下行来提供有关问题的更多信息:

但我仍然只收到上面的错误消息

谁能告诉我是什么导致了这个问题?注释掉我从数据库检索的部分可以消除错误,但我无法解决它

非常感谢

编辑:

Web.config摘录:

<system.web>
    <compilation debug="true"/>
    <deployment retail="false" />
    <customErrors mode="Off">
    </customErrors>
    <httpHandlers>
      <add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
    </httpHandlers>

    <pages
        validateRequest="false"
        pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxx"
        pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxx"
        userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx">
      <controls>
        <add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxx" namespace="System.Web.Mvc" tagPrefix="mvc" />
      </controls>
    </pages>
  </system.web>

我也遇到过类似的问题,我遇到了很多陷阱。我将尝试提供他们的完整列表,以帮助您检查他们:

  • 允许在IIS中浏览目录
  • 在物理保存网站的文件夹中,检查IUSR和IIS_IUSR是否具有读取和浏览权限
  • 检查是否允许访问防火墙中的端口
  • 检查IP地址是否正确。您的外部IP可能不会重定向到内部IP。或者(我犯了新手的错误)你试图浏览内部IP而不是外部IP

我希望这会有所帮助。如果有任何问题,请不要害怕提问。

您可以禁用部署到IIS的应用程序中的customErrors,以便查看有关错误的更多详细信息。请参见此处:另外:从fiddler输出中,您可以看到找不到/Scripts/Application.js(404)。可能~/Scrips/Application.js可以工作。您在另一台计算机上启用了匿名身份验证吗?如果您使用Windows身份验证连接到数据库,则最常见的原因是您在另一台计算机上连接的帐户是asp_net标识,对于所需的数据库访问级别,这是不允许的。@ctrucza我已经尝试了该问题的所有内容,不幸的是,仍然没有留下合理的错误消息。在我的web.config中,我只简单地放了一句:“。谢谢你的建议!想不到的只是一个想法(来自同一篇文章):在machine.config中你有什么想法吗?谢谢你的回复。不幸的是,我已经验证了所有这些设置是正确的,问题仍然存在。啊,这让我找到了我的解决方案,谢谢。我最终应用了您建议的所有设置,重新启动了IIS。没有什么。删除了我的machine.config文件,保存了新版本,停止了IIS,重新启动了我的电脑,重新启动了IIS,将machine.config的新版本保存到相关的配置文件夹中(使用以管理员身份运行的Visual Studio 12),现在我已检索到一条错误消息。最后谢谢!:)