我收到了一個令人困惑的錯誤,我不太清楚爲什麼。當你有兩個ActionResults時,通常會出現這種錯誤,忘記[HttpPost]
。但正如你所看到的,我有[HttpPost]
那裏,所以有什麼可能導致這個問題?已經使用相同的參數類型定義了名爲'Search'的成員
錯誤:Type 'PersonalWebsite.Controllers.BlogController' already defines a member called 'Search' with the same parameter types Controllers\BlogController.cs
和代碼:
//
// GET: /Blog/Search
public virtual ActionResult Search()
{
return RedirectToAction(MVC.Blog.Index());
}
//
// POST: /Blog/Search
[HttpPost]
[ValidateInput(false)]
public virtual ActionResult Search(SearchViewModel model)
{
// irrelevant code snipped
return View(model);
}
有在該控制器中沒有定義任何其他Search()
方法。這很奇怪。
任何想法?
什麼是基類? – haim770
'公共部分類BlogController:Controller' - 通用基類 –
你可以發佈整個控制器嗎?當你遇到你提到的錯誤時, – CodeCaster