我有一個asp.net MVC 4應用有以下索引操作:如何重定向到mvc控制器上的另一個動作?
public ActionResult Index()
{
if (User.IsInRole("dealer"))
{
return View(db.Commissions.Where(c => c.Dealer.Name == User.Identity.Name));
}
else
{//admin
return View(db.Commissions);
}
}
我想我的頁面重定向到另一個MVC行動稱爲過濾器,但不能把它與此代碼完成的:
$(function() {
jQuery.noConflict()
$("#datefrom").datepicker();
$("#dateto").datepicker();
$("#btnfilter").click(function() {
$.ajax({
type: "get",
url: "/commissions/filter/",
data:{'from':$("#datefrom").val(),to:$("#dateto").val()}
,success: function(result){
if(result.Success){
window.location = "/Filter/Commissions" + $("#datefrom").val() + $("#dateto").val();
}
}
});
});
});
這是篩選器操作:
public ActionResult Filter(DateTime from, DateTime to)
{
if (User.IsInRole("dealer"))
{
return View(db.Commissions.Where(c => c.Dealer.Name == User.Identity.Name && c.CreatedDate>=from && c.CreatedDate <=to));
}
else
{//admin
var test = db.Commissions.Where(c => c.CreatedDate >= from && c.CreatedDate <= to);
return View(db.Commissions.Where(c=>c.CreatedDate >= from && c.CreatedDate <= to));
}
}
的篩選器操作被擊中的服務器上,但我得到以下錯誤,當我在看小提琴手:
[InvalidOperationException: The view 'filter' or its master was not found or no view engine supports the searched locations. The following locations were
我該如何解決這個問題?
查看文件Filter.cshtml是否存在? – 2014-03-04 05:29:57
我認爲,在ajax調用成功之後,您傳遞的是錯誤的url。而不是「/過濾器/佣金」,必須使用「/佣金/過濾器」 – 111