I am trying to create a test SurfaceController and view in Umbraco 7. Following the details in the documentation
I think I need to create a plugin controller.
I have created a very simple one and put the controller in an area ie
/Umbraco/TimCDev/timCTest.cs
I have put the corresponding view
/Umbraco/App_Plugins/Views/Shared/timCTest.cshtml
I then forced Umbraco to recompile by editing and saving web.config (I am using a hosted version of Umbraco, so don't have a VIsual Studio project).
I then browsed to
(domain)/Umbraco/TimCDev/timCTest
and get the following error
Parser Error Message: It is an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level. This
error can be caused by a virtual directory not being configured as an
application in IIS.
Have I done something wrong, or is this a config change needed?
My controller, by the way is
using System.Web.Mvc;
using Umbraco.Web.Mvc;
using Umbraco.Web.Mvc.SurfaceController
[PluginController("TimCDev")]
public class timCTestController : Umbraco.Web.Mvc.SurfaceController
{
public ActionResult Index()
{
return Content("Just a test");
}
}
Creating a surface controller
I am trying to create a test SurfaceController and view in Umbraco 7. Following the details in the documentation
I think I need to create a plugin controller.
I have created a very simple one and put the controller in an area ie
I have put the corresponding view
I then forced Umbraco to recompile by editing and saving web.config (I am using a hosted version of Umbraco, so don't have a VIsual Studio project).
I then browsed to (domain)/Umbraco/TimCDev/timCTest
and get the following error
Have I done something wrong, or is this a config change needed?
My controller, by the way is
Hi Tim,
First of all, please, place your timCTest.cs file to App_Code folder. Read more - https://msdn.microsoft.com/en-us/library/t990ks23.aspx
This is only place where you can put .cs files without compiling it to dlls.
Next - ask again, we will help you with pleasure.
Thanks,
Alex
Hi Tim,
Did you solve issue?
Can you share your experiece?
Thanks,
Alex
Alex
Sorry for delay, got sidetracked with other projects non Umbaco ;-(
I put the cs files but when I browse to it
www.mydomain.com/timctest
I get a 404 error.
Do I need to set up some routing?
Hi Tim,
SurfaceControllers are routing by default table, so yes, you have to create route for it.
Hi Tim,
moving the cs file to App_Code was correct. But I think the url you call is not.
When using the PluginController attribute the routing is used like an mvc area. Think it should be mydomain.com/TimCDev/timCTest/.
Maybe try that.
Regards David
is working on a reply...