2013-07-22 36 views
0

我在調試部署到IIS的MVC ASP.NET網頁時遇到了可怕的麻煩。該網站完全在PC上的本地主機上運行。當我瀏覽到然而在同一網絡上的不同PC上的網頁,我得到這個錯誤:錯誤500瀏覽到在本地主機上正常運行的網頁

http://i.stack.imgur.com/N359Q.png

與Fiddler2進一步檢查給我下面的信息,唯一的調試信息,我似乎可以從得到此解決方案:

Fiddler2 info

這裏是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> 
+0

您可以禁用應用程序中的customErrors部署到IIS,以便您可以看到有關500錯誤的更多詳細信息。看到這裏:http://stackoverflow.com/questions/101693/customerrors-mode-off – ctrucza

+0

另外:從提琴手輸出,你可以看到/腳本/應用程序。無法找到js(404)。可能〜/ Scrips/Application.js會起作用。 – ctrucza

+0

您是否在另一臺計算機上啓用了匿名身份驗證?如果您使用Windows身份驗證連接到數據庫,那麼最常見的原因是您在另一臺計算機上連接的帳戶是asp_net標識,該標識不會被授予所需級別的數據庫訪問權限。 – dash

回答

0

我有類似的問題,也有很多陷阱,我碰到。我會盡量提供他們的完整名單,以幫助您檢查一下它們:

  • 允許在IIS中的文件夾,其中的網站被物理保存在
  • 目錄瀏覽,檢查IUSR和IIS_IUSR是否有足夠的權限讀取並瀏覽
  • 檢查,您是否允許訪問您的防火牆端口
  • 檢查IP地址是否正確。有可能您的外部IP不會重定向到內部IP。或者,也許(我犯了菜鳥錯誤),你試圖瀏覽內部IP而不是外部。

我希望這會有所幫助。如果有任何問題,不要害怕問。

+0

感謝您的迴應。不幸的是,我已經驗證了所有這些設置是正確的,問題仍然存在。 –

+0

啊,這導致我的解決方案,謝謝。我最終應用了您建議的所有設置,重新啓動IIS。沒有。刪除我的machine.config文件,保存一個新版本,停止IIS,重新啓動我的電腦,重新啓動IIS,將新版本的machine.config保存到相關的配置文件夾中(使用以管理員身份運行的Visual Studio 12),現在已經檢索一條錯誤消息。最後。謝謝 ! :) –

相關問題