我在調試部署到IIS的MVC ASP.NET網頁時遇到了可怕的麻煩。該網站完全在PC上的本地主機上運行。當我瀏覽到然而在同一網絡上的不同PC上的網頁,我得到這個錯誤:錯誤500瀏覽到在本地主機上正常運行的網頁
與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>
您可以禁用應用程序中的customErrors部署到IIS,以便您可以看到有關500錯誤的更多詳細信息。看到這裏:http://stackoverflow.com/questions/101693/customerrors-mode-off – ctrucza
另外:從提琴手輸出,你可以看到/腳本/應用程序。無法找到js(404)。可能〜/ Scrips/Application.js會起作用。 – ctrucza
您是否在另一臺計算機上啓用了匿名身份驗證?如果您使用Windows身份驗證連接到數據庫,那麼最常見的原因是您在另一臺計算機上連接的帳戶是asp_net標識,該標識不會被授予所需級別的數據庫訪問權限。 – dash