我想用Couchbase後端構建一個Web應用程序。未找到'索引'或其主人的視圖或沒有視圖引擎支持搜索的位置
試圖做的所有IM是返回所有的 「形式」,但我得到這個錯誤 The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched: ~/Views/forms/Index.aspx ~/Views/forms/Index.ascx ~/Views/Shared/Index.aspx ~/Views/Shared/Index.ascx ~/Views/forms/Index.cshtml ~/Views/forms/Index.vbhtml ~/Views/Shared/Index.cshtml ~/Views/Shared/Index.vbhtml
這裏是我的控制器:
public class FormsController : Controller
{
public FormRepository formRepository { get; set; }
public FormsController()
{
formRepository = new FormRepository();
}
//
// GET: /Forms/
public ActionResult Index()
{
var forms = formRepository.GetAll();
return View(forms);
}
}
這裏是FormRepository:
public class FormRepository : RepositoryBase<Form>
{
}
這裏是RepositoryBase:
public abstract class RepositoryBase<T> where T : ModelBase
{
private readonly string _designDoc;
protected static CouchbaseClient _Client { get; set; }
static RepositoryBase()
{
_Client = new CouchbaseClient();
}
public RepositoryBase()
{
_designDoc = typeof(T).Name.ToLower().InflectTo().Pluralized;
}
public virtual IEnumerable<T> GetAll()
{
return _Client.GetView<T>(_designDoc, "all", true);
}
}
這裏是我的索引:
@model IEnumerable<QuickQuote.Models.Form>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.FormTitle)
</th>
<th>
@Html.DisplayNameFor(model => model.Type)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.FormTitle)
</td>
<td>
@Html.DisplayFor(modelItem => item.Type)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
@Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
</td>
</tr>
}
</table>
這裏是我的Global.asax.cs:
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterModelViews(IEnumerable<Assembly> assemblies)
{
var builder = new ViewBuilder();
builder.AddAssemblies(assemblies.ToList());
var designDocs = builder.Build();
var ddManager = new DesignDocManager();
ddManager.Create(designDocs);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
RegisterModelViews(new Assembly[] { Assembly.GetExecutingAssembly() });
}
}
有什麼事情做的Couchbase認爲我創建或者是別的東西? 請幫忙!我想在這個階段做的是GetAll()
返回存儲在Couchbase中的所有文件,但只要我做了localhost/forms
它就會引發此錯誤。
我認爲它couchbase AT的不相關所有。在stackoverflow上有一些類似的問題。 [其中之一](http://stackoverflow.com/questions/2269220/the-view-index-or-its-master-was-not-found)。 – m03geek