user4071723
user4071723

Reputation:

Action Name Attribute Not Linking to Correct View()

I'm Trying to Overload an ActionResult in MVC(4) so that It can return the same view.

[ValidateInput(false)]
public ActionResult SearchQuery(string SearchTerm, bool isAdvanced = false)
{
    return View(new SearchViewModel(SearchTerm, 50, 0, -1, false, 0, null, isAdvanced));
}

[ActionName("BatchSearchQuery")]
[ValidateInput(false)]
public ActionResult SearchQuery(SearchViewModel SVM)
{
    return View(SVM);
}

However when I Call the BatchSearchQuery it returns an error "The view 'BatchSearchQuery' or its master was not found or no view engine supports the searched locations."

Does Anybody Know How I could Return the Correct View from here?

Upvotes: 0

Views: 573

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1039438

You can specify the view name when rendering it:

[ActionName("BatchSearchQuery")]
[ValidateInput(false)]
public ActionResult SearchQuery(SearchViewModel SVM)
{
    return View("SearchQuery", SVM);
}

Upvotes: 1

Related Questions