2014-10-27 31 views
1

我想弄清楚如何獲得一個簡單的Contact Form SurfaceController工作。問題是,當我嘗試導航到「聯繫我們」頁面時,我收到了「路由表中沒有路由與提供的值匹配」。錯誤。如何解決在Umbraco 7.1.8中使用SurfaceController時無路徑錯誤?

我的面控制器:

namespace UmbracoSurface2.Controllers 
{ 
    public class ContactFormSurfaceController : SurfaceController 
    { 
     public ActionResult Index() 
     { 
      return PartialView("ContactForm", new ContactFormViewModel()); 
     } 
    } 
} 

我的ContactForm部分:

@model UmbracoSurface2.Models.ContactFormViewModel 

<form> 
    <div class="controls controls-row"> 
     @Html.TextBoxFor(m => m.Name) 
     @Html.TextBoxFor(m => m.Email) 
    </div> 
    <div class="controls"> 
     @Html.TextAreaFor(m => m.Message, new { rows="5" }) 
    </div> 
    <div class="controls"> 
     <button id="contact-submit" type="submit" class="btn btn-primary input-medium pull-right">Submit</button> 
    </div> 
</form>  

和我的模板:

@inherits Umbraco.Web.Mvc.UmbracoTemplatePage 
@{ 
    Layout = "Master.cshtml"; 
} 
@Html.Action("Index", "ContactFormController") 

礦和截屏和例子我」之間的一個很大的區別我發現我在使用Visual Studio 2013,所以ASP.NET網站模板有一個較新版本的MVC我必須刪除它才能安裝UmbracoCms NuGet軟件包。我也嘗試過,沒有在開始時向項目添加MVC。

任何幫助/建議,將不勝感激,

傑森

+0

SurfaceControllers只爲用戶交互。所以例如一個表單的帖子。你必須使用RenderMvcController。 http://our.umbraco.org/documentation/Reference/Mvc/custom-controllers – 2014-10-28 09:36:53

+0

我不確定我所做的不是用戶交互,尤其是因爲它是Umbraco團隊使用的確切示例。無論如何,我已經發布了下面的解決方案。 – Jason 2014-10-28 14:09:52

回答

2

好吧,按照丹的回答here上一把umbraco論壇上,這個問題是我的一個愚蠢的錯誤。模板中的@ Html.Action行應該是:

@Html.Action("Index", "ContactFormSurface") 

傑森

+0

從代碼窗口複製/粘貼可能是一個真正的痛苦... – 2016-05-30 13:58:27

相關問題