using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Mvc;
using MyProject.Core.Constants;
using MyProject.Core.ViewModels; using Umbraco.Web.Models;
using Umbraco.Web.Mvc;
namespace ChilternThrustBore.Core.Controllers
{
public class ExampleController : SurfaceController
{
/// <summary>
/// Example of calling an MVC route, you would use
/// /umbraco/surface/{controllername}/{action}/{id}
/// So this works if you put in /umbraco/surface/example
/// </summary>
/// <returns></returns>
public ActionResult Index()
{
return Content("hello world");
}
}
}
But when I try to browse to see the hello world via
/umbraco/surface/example/
I get the following error?
Attempt by method 'MyProject.Core.Controllers.ExampleController.Index()' to access method 'System.Web.Mvc.Controller.Content(System.String)' failed.
Any ideas? I can't see anything wrong with it? The controller is getting hit, but it throws this wobbly as soon as it hits this part?
No you can run it without being suffixed. This is a copy of a working 'play' solution and its all of a sudden not working on this one only? I'll keep tinkering.
Just to let you know. I'm a twat. Ignore the above. I had left the old binaries in the bin folder of the web project, so it was trying to load both. All working fine now.
So for anyone reading this, you don't need to prefix 'SurfaceController' now like you did in v5. The above works just fine.
I had binaries left over from the project I copied this one from. Also check your project debug/bin folders. A clean solution simply does not get rid of all the old binaries if you are in the same position I am.
Surface Controller Not Working?
I have the following
But when I try to browse to see the hello world via
I get the following error?
Any ideas? I can't see anything wrong with it? The controller is getting hit, but it throws this wobbly as soon as it hits this part?
Hmm can't edit the above post now
Don't you need ExampleSurfaceController instead of ExampleController?
/Dirk
As Dirk said, if it follows the same rules as V5, it had to be suffixed ..SurfaceController
Matt
No you can run it without being suffixed. This is a copy of a working 'play' solution and its all of a sudden not working on this one only? I'll keep tinkering.
Just to let you know. I'm a twat. Ignore the above. I had left the old binaries in the bin folder of the web project, so it was trying to load both. All working fine now.
So for anyone reading this, you don't need to prefix 'SurfaceController' now like you did in v5. The above works just fine.
I was Trying the SurfaceController but got the same problem (version 4.11), I can't figure out wat the problem is
Code
public class HomeSurfaceController : SurfaceController
{
[ChildActionOnly]
public ActionResult test()
{
return Content("Yep!");
}
}
Error
Attempt by method 'TestProject.Controllers.HomeSurfaceController.test()' to access method 'System.Web.Mvc.Controller.Content(System.String)' failed.
The strange thing is when I just return a string instead of an ActionResult it works
public class HomeSurfaceController : SurfaceController
{
[ChildActionOnly]
public string test()
{
return "Yep~";
}
}
ps (sorry for not posting the code in those codeblocks when i put them in the preformatted blocks its a mess)
I get the same error.
Lee, what binaries had you left in the bin directory? cheers
I had binaries left over from the project I copied this one from. Also check your project debug/bin folders. A clean solution simply does not get rid of all the old binaries if you are in the same position I am.
I've got this and it works:
@Html.Action("Part", "Menu", Model)
public class MenuController : SurfaceController
{
[ChildActionOnly]
public ActionResult Part(RenderModel Model)
{
IPublishedContent HomeContent = Umbraco.TypedSearch("Home").First<IPublishedContent>();
MenuViewModel MVM = new MenuViewModel();
MVM.Children = Umbraco.Content(HomeContent.Id).Children.Where("Visible");
return PartialView("Menu", MVM);
}
}
is working on a reply...