代码之家  ›  专栏  ›  技术社区  ›  IbraHim M. Nada

如何在Umbraco Controller中调用操作?

  •  2
  • IbraHim M. Nada  · 技术社区  · 8 年前

    DocumentType 使用别名 Personal 并创建了一个继承

    我加了两个 Action s、 一个是默认动作,另一个叫做 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

    没有与url“/test”匹配的umbraco文档。

    1 回复  |  直到 7 年前
        1
  •  2
  •   prjseal    8 年前

    我会这样做

    [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);
    }
    

    有关此代码片段来源的完整背景,请参阅本文。

    http://www.codeshare.co.uk/blog/how-to-search-by-document-type-and-property-in-umbraco/