如何在 Umbraco 控制器中调用一个动作?
How To call An Action In Umbraco Controller?
我用别名 Personal
创建了一个 Umbraco DocumentType
并创建了一个继承
的控制器
Umbraco.Web.Mvc.RenderMvcController
我加了两个Action
,一个是默认动作,一个叫Test
。
如何从 Personal
控制器触发 Test
动作?
public class PersonalController : Umbraco.Web.Mvc.RenderMvcController
{
// GET: Personal
public override ActionResult Index(RenderModel model)
{
return base.Index(model);
}
public String Test(RenderModel model)
{
return "fff";
}
}
当我这样输入 url 时:localHost/personal/test
它显示:
No umbraco document matches the url '/test'.
哪个是对的,怎么称呼呢?
我会这样做
[HttpPost]
public ActionResult SubmitSearchForm(SearchViewModel model)
{
if (ModelState.IsValid)
{
if (!string.IsNullOrEmpty(model.SearchTerm))
{
model.SearchTerm = model.SearchTerm;
model.SearchGroups = GetSearchGroups(model);
model.SearchResults = _searchHelper.GetSearchResults(model, Request.Form.AllKeys);
}
return RenderSearchResults(model.SearchResults);
}
return null;
}
public ActionResult RenderSearchResults(SearchResultsModel model)
{
return PartialView(PartialViewPath("_SearchResults"), model);
}
查看此博客 post 以了解此代码段来源的完整上下文。
http://www.codeshare.co.uk/blog/how-to-search-by-document-type-and-property-in-umbraco/
我用别名 Personal
创建了一个 Umbraco DocumentType
并创建了一个继承
Umbraco.Web.Mvc.RenderMvcController
我加了两个Action
,一个是默认动作,一个叫Test
。
如何从 Personal
控制器触发 Test
动作?
public class PersonalController : Umbraco.Web.Mvc.RenderMvcController
{
// GET: Personal
public override ActionResult Index(RenderModel model)
{
return base.Index(model);
}
public String Test(RenderModel model)
{
return "fff";
}
}
当我这样输入 url 时:localHost/personal/test
它显示:
No umbraco document matches the url '/test'.
哪个是对的,怎么称呼呢?
我会这样做
[HttpPost]
public ActionResult SubmitSearchForm(SearchViewModel model)
{
if (ModelState.IsValid)
{
if (!string.IsNullOrEmpty(model.SearchTerm))
{
model.SearchTerm = model.SearchTerm;
model.SearchGroups = GetSearchGroups(model);
model.SearchResults = _searchHelper.GetSearchResults(model, Request.Form.AllKeys);
}
return RenderSearchResults(model.SearchResults);
}
return null;
}
public ActionResult RenderSearchResults(SearchResultsModel model)
{
return PartialView(PartialViewPath("_SearchResults"), model);
}
查看此博客 post 以了解此代码段来源的完整上下文。
http://www.codeshare.co.uk/blog/how-to-search-by-document-type-and-property-in-umbraco/