2014-12-09 5 views
0

Asp.Net MVC로 개발 한 프로젝트가 있습니다. 뷰 엔진을 면도기와 면도기 (.cshtml) 모두 IIS (IIS 7)에서 작동하지 않습니다. 모든 설정 (예 : 처리기 매핑, runAllManagedModulesForAllRequests, 웹 페이지 : 사용, 웹 페이지 : 버전)과 같은 모든 설정이 제대로 표시됩니다. 피들 러를 통해 오류를 검사하지만 IIS 로그가 깨끗하게 나타나면 "500 내부 서버 오류"을 오류로 반환하십시오. 이 오류의 원인은 무엇입니까?IIS에서 MVC 면도 페이지가 작동하지 않습니다.

+0

어떤 예외가 발생하고 있습니까? .NET 오류 일 경우 유용한 무언가를 제공하는 노란색 화면이 나타납니다. –

+0

또한 Windows 이벤트 로그, 특히 응용 프로그램 로그를 확인하십시오. –

+0

오류 지정 예외를 반환하지 않습니다. 면도 페이지가 빈 페이지로 렌더링됩니다 (흰색 페이지). Fiddler를 검사하는 동안이 예외가 발생했습니다. –

답변

0

최근에 릴리스 된 Windows 보안 업데이트 MS14-059이 가능성이 있습니다.

기본적으로이 업데이트는 MVC 4.0.0.0을 완전히 제거하고 서버에서 4.0.0.1로 바꾸며 빌드가 깨진 많은 사람들에게 슬픔을 안겨줍니다. 대안은 일반적으로 관련 assemblyBinding 리디렉션을 Web.config에 추가하는 것이지만 다른 솔루션 인 check here이 있습니다.

<runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
      <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> 
      <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.1" /> 
     </dependentAssembly> 
    </assemblyBinding> 
</runtime> 
0

IIS 웹 풀이 앱과 동일한 .net 버전을 사용하고 있는지 확인하십시오.

0

면도기 엔진 버전으로 인해 문제가 발생했습니다. 양식 페이지 (.aspx)를 기존 페이지로 바꿔야했습니다. 문제는 해결되었지만 해결책은 아닙니다.

문제점 세부 :

[A] System.Web.WebPages.Razor.Configuration.HostSection는 [B] System.Web.WebPages.Razor.Configuration.HostSection로 전송할 수 없다. A 유형 'C : \ Windows \ Microsoft.Net \ assembly \ GAC_MSIL \ System'의 컨텍스트 '기본값'에서 'System.Web.WebPages.Razor, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35' .Web.WebPages.Razor \ v4.0_1.0.0.0__31bf3856ad364e35 \ System.Web.WebPages.Razor.dll '. 형식 B는 'C : \ Windows \ Microsoft.Net \ assembly \ GAC_MSIL \ System'위치의 'Default'컨텍스트에서 'System.Web.WebPages.Razor, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35' .Web.WebPages.Razor \ v4.0_2.0.0.0__31bf3856ad364e35 \ System.Web.WebPages.Razor.dll '.

0
, 잘 작동 면도칼을 incorportaes 및

을 heres 내 cshtml은

@using System.Data 
@model IEnumerable<CampRoll.Models.Camp> 

<div class="container"> 

<h2>@ViewBag.PageTitle</h2> 
<p> 
    @Html.ActionLink("Create New", "Create", null, new { @class = "btn btn-success" }) 
</p> 
<div class="row"> 
    <div class="col-xs-8"> 
     <table id='campsTable' class="table table-condensed table-striped"> 
      <tr> 
       <th> 
        @Html.DisplayNameFor(model => model.Title) 
       </th> 
       <th> 
        @Html.DisplayNameFor(model => model.Leader) 
       </th> 
       <th> 
        @*@Html.ActionLink("StartDate",null,new{[email protected]}, 
         new{@class="btn btn-info btn-xs"})*@ 
        <a class="btn btn-xs btn-info" href="@Url.Action("Index", new { sortOrder = @ViewBag.dateOrder })"> 
         @if (ViewBag.dateOrder == "ascDate") 
         { 
          <span class="glyphicon glyphicon-arrow-down" aria-hidden="true"></span> 
         } 
         else if (ViewBag.dateOrder == "descDate") 
         { 
          <span class="glyphicon glyphicon-arrow-up" aria-hidden="true"></span> 

         } 
         &nbsp;StartDate 
        </a> 
       </th> 
       <th><a class="btn btn-xs btn-info" href="@Url.Action("Index", new { sortOrder = @ViewBag.numberOrder })"> 
        @if (ViewBag.numberOrder == "descNumber") 
        { 
         <span class="glyphicon glyphicon-arrow-up" aria-hidden="true"></span> 
        } 
        else if (ViewBag.numberOrder == "ascNumber") 
        { 
         <span class="glyphicon glyphicon-arrow-down" aria-hidden="true"></span> 

        } 
        &nbsp;Number 
       </a></th> 
       <th></th> 
      </tr> 

      @foreach (var item in Model) 
      { 
       <tr> 
        <td> 
         <span class="btn btn-xs btn-warning" 
           onclick="showChildren('@item.CampId')">@Html.DisplayFor(modelItem => item.Title)</span> 
        </td> 
        <td> 
         <span class="btn btn-xs btn-danger" onclick="showLeader('@item.LeaderId')"> 
          @Html.DisplayFor(modelItem => item.Leader.FirstName) 
         </span> 
        </td> 
        <td> 
         @Html.DisplayFor(modelItem => item.StartDate) 
        </td> 
        <td> 
         @if (item.Children.Count == 0) 
         { 
          <p style="margin: 0px">None</p> 
         } 
         else 
         { 
          @Html.DisplayFor(modelItem => item.Children.Count) 
         } 

        </td> 
        <td> 
         @Html.ActionLink("Edit", "Edit", new { id = item.CampId }, new { @class = "btn btn-info btn-xs" }) 
         @Html.ActionLink("Details", "Details", new { id = item.CampId }, new { @class = "btn btn-info btn-xs" }) 
         @Html.ActionLink("Delete", "Delete", new { id = item.CampId }, new { @class = "btn btn-danger btn-xs" }) 
        </td> 
       </tr> 
      } 

     </table> 
    </div> 
    <div class="col-xs-4"> 
     <div id="Detail"></div> 
     <div> 
      <form id="CreateChild" hidden=""> 
       <div class="form-group" style="margin-top: 10px"> 
        <input type="hidden" name="campId"> 
        <input type="submit" value="Add" class="btn btn-xs btn-success" style="margin-top: -5px;" /> 
        &nbsp;<input type="text" name="name"><span>&nbsp;to Camp</span> 
       </div> 
      </form> 
      <form id="EditChild" hidden=""> 
       <div class="form-group" style="margin-top: 10px"> 
        <input type="hidden" name="campId"><input type="hidden" name="childId"> 
        <input type="hidden" name="sex"> 
        <input type="submit" value="Save" class="btn btn-xs btn-success" style="margin-top: -5px;" /> 
        <input type="button" onclick="$('#EditChild').hide(); $('#CreateChild').show();" value="Cancel" class="btn btn-xs btn-warning" style="margin-top: -5px;" /> 
        <input type="text" name="name" value=""> 
        <div style="margin:-5px 5px" class='badge alert-info'><input type="radio" name="male" value="">M 
        <input type="radio" name="female" value="">F</div> 
       </div> 
      </form> 
     </div> 
    </div> 
    <!-- End Details --> 
</div> 

@section scripts 
    { 
<script> 
    $(function() { // ready event 
     toastr.info('Welcome to Camp Roll'); 
     // Handle toggle of male/female 
     $('#EditChild :input[name="male"]').click(function() { 
      $('#EditChild :input[name="female"]').prop('checked', false); 
     }); 
     $('#EditChild :input[name="female"]').click(function() { 
      $('#EditChild :input[name="male"]').prop('checked', false); 
     }); 
     @if (Model.Any()) 
     { 
      // On display show the children in the first camp 
      <text> 
       showChildren(@Model.First().CampId); 
      </text> 
     } 
    }); 

    // POSTback of creating a new child 
    $('#CreateChild').submit(function() { 
     if ($(this).find('input[name="name"]').val()!="") { 
      $.ajax({ 
       url: '@Url.Action("CreateChild")', 
       type: "POST", 
       data: $(this).serialize(), // serialize the input controls for this form '#CreateChild' 
       success: function() { 
        showChildren($('form').find('input[name="campId"]').val()); // refresh the table of children 
        toastr.info($('form').find('input[name="name"]').val() + ' Added'); // toast 
        $('form').find('input[name="name"]').val(""); // zero out the add child box 
       } 
      }); 
     } 
     return false; 
    }); 

    // Display leader of the camp 
    function showLeader(leaderId) { 
     // When Leader name clicked, invoke Controler action method to return partial view and ajax it into place 
     @*$('#Detail').load('@Url.Action("LeaderById")' + '?id=' + leaderId).fadeIn(1000);*@ 
     $.ajax({ 
       url: '@Url.Action("LeaderById")', 
       data: { id: leaderId }, 
       success: function(data) { 
        $('#Detail').hide(); 
        $('#CreateChild').hide(); 
        $('#Detail').html(data); 
        $('#Detail').fadeIn(1000); 
       }, 
       error: function() { 
        $('#Detail').html("<h3>Couldn't find a leader</h3>"); 
       } 
      } 
     ); 
    } 

    // ajax Display of Children in the selected camp 
    function showChildren(campId) { 
     // When Leader name clicked, invoke Controler action method to return partial view and ajax it into place 
     $.ajax({ 
      type: "GET", 
      url: '@Url.Action("ChildrenById")', 
      data: { id: campId }, 
      success: function(data) { 
       $('#Detail').hide(); 
       $('#CreateChild').hide(); 
       $('#Detail').html(data); 
       $('#Detail').fadeIn("slow"); 
       $('#CreateChild').find('input[name="campId"]').val(campId); // set campId for the Create Child form 
       $('#CreateChild').find('input[name="name"]').val(""); 
       $('#CreateChild').fadeIn("slow"); 
      }, 
      error: function(data) { 
       $('#Detail').html('<h3>Error in retrieval</h3>'); 
      } 
     }); 
    } 

    function showEditChild(campId, childId, childName, sex) { 
     $('#EditChild').slideDown("fast"); 
     $('#EditChild').show(); 
     $('#CreateChild').hide(); 
     $('#EditChild :input[name="childId"]').val(childId); 
     $('#EditChild :input[name="campId"]').val(campId); 
     $('#EditChild :input[name="name"]').val(childName); 
     if (sex == 'Male') { 
      $('#EditChild :input[name="male"]').prop('checked', true); 
      $('#EditChild :input[name="female"]').prop('checked', false); 
     } else { 
      $('#EditChild :input[name="female"]').prop('checked', true); 
      $('#EditChild :input[name="male"]').prop('checked', false); 
     } 
    } 

    $('#EditChild').submit(function() { 
     if ($('#EditChild :input[name="male"]').prop('checked') == true) { 
      $('#EditChild :input[name="sex"]').val('male'); 
     } else { 
      $('#EditChild :input[name="sex"]').val('female'); 
     } 
     $.ajax({ 
      url: '@Url.Action("UpdateChild")', 
      type: "POST", 
      data: $(this).serialize(), 
      success: function() { 
       $('#EditChild').hide(); 
       showChildren($('#EditChild :input[name="campId"]').val()); // refresh the table of children 
       toastr.info($('#EditChild :input[name="name"]').val() + ' Updated'); 
      }, 
      error: function(data) { 
       $('#Detail').html('<h3>Could not update Child record</h3>'); 
      } 
     }); 
     return false; 
    }); 

    function deleteChild(childId, campId) { 
     $.ajax({ 
      type: "POST", 
      url: '@Url.Action("DeleteChild")', 
      data: { id: childId, campId: campId }, 
      success: function(data) { 
       $('#Detail').hide(); 
       $('#CreateChild').hide(); 
       $('#Detail').html(data); 
       $('#Detail').fadeIn("slow"); 
       $('#CreateChild').find('input[name="campId"]').val(campId); // set campId for the Create Child form 
       $('#CreateChild').find('input[name="name"]').val(""); 
       $('#CreateChild').fadeIn("slow"); 
      }, 
      error: function(data) { 
       $('#Detail').html('<h3>Error in retrieval</h3>'); 
      } 
     }); 
    } 
</script> 

}

0

삭제 부트 스트랩

@model CampRoll.Models.Camp 

<div class="container"> 
<div class="panel panel-info"> 
    <div class="panel-heading"> 
     <h4>Confirm deletion of @Model.Title</h4> 
    </div> 
</div> 
<div class="panel-body"> 

    <fieldset> 
     <legend>Details</legend> 

     <div> 
      @Html.DisplayFor(model => model.Title) starting&nbsp; 
      @Html.DisplayFor(model => model.StartDate) 
      @using (Html.BeginForm()) 
      { 
       @Html.AntiForgeryToken() 
        <input type="submit" value="Delete" class="btn btn-danger" /> 
      } 
     </div> 
    </fieldset> 

</div> 
<div class="panel-footer"> 
    @Html.ActionLink("Back to List", "Index", null, new { @class = "btn btn-success" }) 
</div> 

0

@using System.Web.UI.WebControls @using CA2.Models @model의 CA2.Models.Movie

<div class="container"> 
<div class="panel panel-info"> 
    <div class="panel-heading"> 
     <div class="lead">Create Movie</div> 
    </div> 
    <div class="panel-body"> 
     @using (Html.BeginForm()) 
     { 
      @Html.AntiForgeryToken() 
      @Html.ValidationSummary(true) 

      <div class="row"> 
       <div class="form-group col-xs-4"> 
        @Html.LabelFor(model => model.MovieTitle) 
        @Html.TextBoxFor(model => model.MovieTitle, new { @class = "form-control" }) 
        @*@Html.ValidationMessageFor(model => model.MovieTitle)*@ 
       </div> 
       <div class="form-group col-xs-4"> 
        @Html.LabelFor(model => model.Director) 
        @*@Html.TextBoxFor(model => model.StartDate,new { @class = "form-control" })*@ 
        <div class='input-group' id='datetimepicker1'> 
         <input type='text' name="MovieTitle" /> 
         <span class="input-group-addon"></span> 
        </div> 
        @*@Html.ValidationMessageFor(model => model.Director)*@ 
       </div> 
       @*<div class="col-xs-4"> 
        @Html.LabelFor(model => model.Actors) 
        @Html.DropDownList("Actors", 
         new SelectList(ViewBag.Actors, "MovieTitle"), 
         new { @class = "form-control" }) 
       </div>*@ 
      </div> 
      <div> 
       <button class="btn btn-success"><span class="glyphicon glyphicon-plus"></span>Create</button> 
      </div> 
     } 
    </div> 
    <div class="panel-footer"> 
     <a class="btn btn-danger" href="@Url.Action("Index")"> 
      <span class="glyphicon glyphicon-home"></span>&nbsp;Back to List 
     </a> 
     @*@Html.ActionLink("Back to List", "Index",null,new {@class="btn btn-xs btn-info"})*@ 
    </div> 
</div> 

0

편집

@using CA2.Models 
@model CA2.Models.Movie 

<div class="container"> 
<div class="panel panel-info"> 
    <div class="panel-heading"> 
     <h4>Edit @Model</h4> 
    </div> 
</div> 
<div class="panel-body"> 
    @using (Html.BeginForm()) 
    { 
     @Html.AntiForgeryToken() 
     @Html.ValidationSummary(true) 
     <fieldset> 
      <legend>Movie</legend> 
      @Html.HiddenFor(model => model.Id) 
      <div class="row"> 
       <div class="form-group col-xs-4"> 
        @Html.LabelFor(model => model.MovieTitle) 
        @Html.TextBoxFor(model => model.MovieTitle, 
          new { @class = "form-control" }) 
        @Html.ValidationMessageFor(model => model.MovieTitle) 
       </div> 
       <div class="form-group col-xs-4"> 
        @*@Html.LabelFor(model => model.Id) 
        <div class='input-group date' id='datetimepicker1'> 
         <input type='text' name="StartDate" value="@Model.Director" class="form-control" data-date-format="DD/MM/YYYY" /> 
         <span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></span> 
        </div>*@ 
        @*@Html.ValidationMessageFor(model => model.Director)*@ 
       </div> 

       <div class="form-group col-xs-4"> 
        @*@Html.LabelFor(model => model.Actors) 
        @Html.DropDownList("Actors", new SelectList(ViewBag.Actors, "Actors", Model.Actors), 
         new { @class = "form-control" })*@ 
       </div> 
      </div> 
      <div class="form-group"> 
       <input type="submit" class="btn btn-primary" 
         value="Save" /> 
      </div> 
     </fieldset> 
    } 
</div> 
<div class="panel-footer"> 
    @Html.ActionLink("Back to List", "Index", null, new { @class = "btn btn-success" }) 
</div> 

를 만들
관련 문제