【发布时间】:2013-07-22 09:23:22
【问题描述】:
我在调试部署到 IIS 的 MVC ASP.NET 网页时遇到了可怕的麻烦。该网站在制作它的 PC 上的本地主机上完美运行。但是,当我导航到同一网络上另一台 PC 上的页面时,我收到此错误:
使用 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>
还有相关的索引页:
@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>
这些会呈现一个包含 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 的应用程序中的 customErrors,以便查看有关 500 错误的更多详细信息。见这里:stackoverflow.com/questions/101693/customerrors-mode-off
-
另外:从提琴手输出中,您可以看到 /Scripts/Application.js 找不到(404)。可能 ~/Scrips/Application.js 会起作用。
-
您是否在另一台计算机上启用了匿名身份验证?如果您使用 Windows 身份验证连接到数据库,那么最常见的原因是您在另一台机器上连接的帐户是 asp_net 身份,它不会获得所需级别的 db 访问权限。
-
@ctrucza 我已经尝试了该问题中的所有内容,但不幸的是仍然没有任何合理的错误消息。在我的 web.config 中,我简单地输入了:“
”。感谢您的建议! -
意外......只是一个想法(来自同一篇文章):在 machine.config 中你有
吗?
标签: c# sql-server asp.net-mvc razor