c# - Redirecting from cshtml page -


i want redirect different view depending on result of dataset, keep getting returned page on, , can't work out why. drop if statement action gets called once return view new page, returns me current page.

cshtml page

@{ viewbag.title = "search results"; enumerablerowcollection<datarow> custs = viewbag.customers;  bool anyrows = custs.any(); if(anyrows == false) {       html.action("noresults","home");   } // redirect no search results view 

}

controller

 public actionresult noresults()     {        return view("noresults");      } 

view cant too..

@{ viewbag.title = "noresults";  }  <h2>noresults</h2> 

change this:

@{ response.redirect("~/home/noresults");} 

Comments