私はウェブ言語の初心者です。Visual Studio 2010 で .NET プロジェクトを開始しました。これは MVC 4 とカミソリ構造です。
問題は、views フォルダーにフォルダーがあり、そこにビューが含まれていることですが、ビューにアクセスしようとすると、次のエラーが発生しました。
The view 'searchWeb' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Home/searchWeb.aspx
~/Views/Home/searchWeb.ascx
~/Views/Shared/searchWeb.aspx
~/Views/Shared/searchWeb.ascx
~/Views/Home/searchWeb.cshtml
~/Views/Home/searchWeb.vbhtml
~/Views/Shared/searchWeb.cshtml
~/Views/Shared/searchWeb.vbhtml
彼は正しいフォルダを検索していないと思います...しかし、これを変更するにはどうすればよいですか? 私はいくつかのトピックを見ましたが、明らかに新しいviewEngineを作成し、古いものから継承する必要がありますか? 新しいビュー エンジンを作成せずに修正することは可能ですか? または、新しいビュー エンジンの作成方法を教えてもらえますか? ありがとう !
編集:
これは私のhomeController.csです:
namespace Searcher.Controllers
{
public class HomeController : Controller
{
public ActionResult homeWeb()
{
ViewBag.Message = "Searching for sites over the web.";
return View();
}
public ActionResult homeImages()
{
ViewBag.Message = "Searching for images over the web.";
return View();
}
public ActionResult homeVideos()
{
ViewBag.Message = "Searching for videos over the web.";
return View();
}
[HttpPost]
public ActionResult searchWeb()
{
// do something with the search value
return View();
}
}
}
これは、searchWeb を呼び出している私の homeWeb です。
@{
ViewBag.Title = "Search Web";
}
@section featured {
<section class="featured">
<div class="content-wrapper">
<hgroup class="title">
<h1>@ViewBag.Title.</h1>
<h2>@ViewBag.Message</h2>
</hgroup>
</div>
</section>
}
@using (Html.BeginForm("searchWeb", "Home", FormMethod.Post, new { id = "searchForm" }))
{
<div class="main-block">
<p>
<div>
<input size="200px" type="text" name="searchValue" />
</div>
<div>
<input type="submit" value="Submit" />
</div>
</p>
</div>
}