2014-10-03 157 views
1

我嘗試在IIS7中運行ASP.NET MVC5,但是網站只顯示我的cshtml的文本。MVC 5在IIS 7中不工作

我的配置:

GoWireless>基本設置>選擇(.NET Framework版本:沒有管理控制檯,管道模式:經典)

GoWireless>目錄瀏覽>已啓用

Index.cshtml僅顯示此文本

@model IEnumerable @ {Vi ewBag.Title =「Active Directory」; } Active Directory

歡迎,@ User.Identity.Name.Remove(0,User.Identity.Name.IndexOf(「\」) + 1)!

這是GoWireless活動目錄搜索器,您可以使用搜索框 或點擊左上角的其中一個員工以查看 員工的詳細信息。如果您想搜索只存在於GoWireless \ ActiveDirectory中並且不存在於GW_UTA \ ActiveDirectory2 中的 用戶,則可以以完整格式輸入並搜索他的\詳細信息(SamAccountName, GivenName,Surname,Email或EmployeeNumber)中的一個到 搜索框。

瞭解更多

_Layout.cshtml只顯示這段文字

@model IEnumerable 
Toggle navigation Failed to load images 
@User.Identity.Name 
@using (Html.BeginForm("Index", "Home", FormMethod.Post)) { 
@Html.TextBox("search", null, new { @class = "form-control", @placeholder = "Search..." }) 
} 
@foreach (var item in Model) { 
class="active"} href='@Url.Action("Details", "Home", new { id = item.SamAccountName.Replace(".", "_") })'>@item.SamAccountName 
ViewBag.count = 1; } @if (ViewBag.count != 1) { EasyAD.EasyAD ad = new EasyAD.EasyAD("dc1.gowireless.net:389", "gowireless\\ldapuser", "[email protected]#"); System.Data.DataTable dt = ad.GetUsers(ViewBag.search); var count = 0; while (count < dt.Rows.Count) { if (dt.Rows[count]["SamAccountName"].ToString() != null && dt.Rows[count]["SamAccountName"].ToString() !="") { 
class="active"} href='@Url.Action("Details", "Home", new { id = dt.Rows[count]["SamAccountName"].ToString().Replace(".", "_") })'>@dt.Rows[count]["SamAccountName"] 
} else { ViewBag.warning = 1; } count++; } if (dt.Rows.Count <= 0) { ViewBag.count = 0; } } 
@RenderBody() @if (ViewBag.warning == 1) { 
× Warning! someone is containing the employee @ViewBag.search without SamAccountName, Please check manually the GoWireless\\ActiveDirectory. 
} @if (ViewBag.success == 1) { 
× Well Done! @ViewBag.search is successfully updated in ga_uta\\activedirectory. 
} @if (ViewBag.count == 0) { 
× Heads Up! @ViewBag.search is not exist in GW_UTA or GoWireless, maybe you are missing something? 
} @if (ViewBag.error == 1) { 
Oh Snap! 
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum tincidunt est vitae ultrices accumsan. Aliquam ornare lacus adipiscing, posuere lectus et, fringilla augue. 

Some Error Accured 
} 

它應該是這樣的

enter image description here

+1

http://cdonner.com/mvc-5-on-windows-server-2008iis-7。htm – 2014-10-04 14:08:03

+0

@Evgeni謝謝你,我的問題完成了:D – 2014-10-07 02:39:05

回答

6

管理模塊

bin文件夾包含MVC的所有必需組件(MVC 5不需要作爲先決條件進行部署,因爲它是網站部署包的一部分)。

但是,由於某種原因,MVC沒有重寫URL來爲我的網站調用正確的處理程序。所以,在各種Stackoverflow文章和博客帖子中,我終於碰到this one on MSDN後,我有一個突破。它說明了如何使用IIS管理器的GUI到UrlRoutingModule明確添加到web.config中,即使出現瞭如安裝在我的網站:

enter image description here

後我未選中的「只調用的請求到ASP.NET應用程序或託管處理程序「複選框的條目類型更改爲本地(請參閱上面的屏幕截圖),並在我的web.config中出現相應的部分。 IIS突然開始明白<system.webServer>部分(我仍然不知道爲什麼),並且該網站開始呈現MVC視圖。 See more at cdonner...

+1

男人,你救了我!我不斷收到403錯誤,其他文章沒有幫助。 – 2016-01-15 19:46:40