MVC 5在IIS 7中不工作

问题描述:

我尝试在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

管理模块

bin文件夹包含MVC的所有必需组件(MVC 5不需要作为先决条件进行部署,因为它是网站部署包的一部分)。

但是,由于某种原因,MVC没有重写URL来为我的网站调用正确的处理程序。所以,在各种*文章和博客帖子中,我终于碰到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