2016-04-20 25 views
1


我使用的Visual Studio 2012與EntityFramwork4.4
錯誤無法IIS服務器上加載資源(操作方法),但在本地主機上成功運行

我已經創建的視圖VoucherRaisedbyMe和它已經加載局部視圖在div元素。部分視圖有webgrid並在其中加載數據。

其工作正常與本地主機,但後發佈IIS7服務器在其上示出了下面誤差局部視圖
ActionMethod
錯誤:

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost/Voucher/VoucherRaisedbyMePartial

(視圖)VoucherRaisedbyMe

   <table><tr> 
        <td colspan="5"> 
         <div id="gridContent"> 
         </div> 
        </td> 
       </tr> 
      </table> 
<script> 
    $(document).ready(function() { 
     $("#btnGo").click(function() { 
      loadGrid(); 
     });   
    }); 
</script> 
    <script> 
    function loadGrid() { 
     var booksDiv = $("#gridContent"); 
     var items = {}; 
     items.vFinYear = $("#ddl_FinnYear").val(); 
     items.vDeptCode = $("#ddl_Dept").val(); 
     //alert('hi'); 
     $.ajax({ 
      cache: false, 
      type: "POST", 
      contentType: "application/json; charset=utf-8", 
      url: "/Voucher/VoucherRaisedbyMePartial", 
      data: '{items: ' + JSON.stringify(items) + '}', 
      success: function (data) { 
       booksDiv.html(''); 
       booksDiv.html(data); 
      }, 
      error: function (xhr, ajaxOptions, thrownError) { 
       debugger; 
       alert(thrownError); 
       alert('Failed to retrieve data.'); 
      } 
     }); 
    } 
</script> 

(動作方法調用局部視圖)VoucherRaisedbyMePartial

public ActionResult VoucherRaisedbyMePartial(Voucher items) 
{ 
    var VoucherList = new List<Voucher>(); // getting proper list 
    return PartialView("_VoucherRaisedbyMePartial", VoucherList); 
} 

(局部視圖_VoucherRaisedbyMePartial

@model IEnumerable<PVS_WEB.Models.Voucher> 
@{ 
    ViewBag.Title = "WebgridSample"; 
    var grid = new WebGrid(Model, canPage: true, rowsPerPage: 10, selectionFieldName: "selectedRow", ajaxUpdateContainerId: "gridContent"); 
    grid.Pager(WebGridPagerModes.NextPrevious); 
} 
<div id="gridContent"> 
    @grid.GetHtml() 
</div> 
+0

使用'url:「@ Url.Action(」VoucherRaisedbyMePartial「,」Voucher「)」,'而不是 – haim770

+0

非常感謝....你的回答工作 –

回答

0

使用網址: 「@ Url.Action(」 VoucherRaisedbyMePartial」, 「Voucher」)「,insted

謝謝haim770

相關問題