I have a project that uses UmbracoCMS 7.4.1 with Autofac and RouteHijacking.
Installed UmbracoForms last week and everything seemed fine.
But when I try to Post a form I get an error saying the /Views/UmbracoForms/Index.cshtml cannot be found.
I did a test with a custom surfacecontroller
[HttpPost]
public ActionResult Post() {
return CurrentUmbracoPage();
}
and I still get the same error like this:
System.InvalidOperationException: The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/TestSurface/Index.cshtml
~/Views/TestSurface/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
at System.Web.Mvc.ViewResult.FindView(ControllerContext context)
at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
at System.Web.Mvc.Controller.ExecuteCore()
at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
at Umbraco.Web.Mvc.UmbracoPageResult.ExecuteControllerAction(ControllerContext context, IController controller)
at Umbraco.Web.Mvc.UmbracoPageResult.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
I do not use any custom routes.
I downloaded the UmbracoCMS source and tried debugging, and what I could see was that the controllerFactory resolves the correct controller (in UmbracoPageResult.cs) but when ExecuteControllerAction is called the ControllerContext RequestContext passed to the controller.Execute() isn't correct. The RouteData still points to UmbracoForms.
I have tried to reinstall UmbracoCMS 7.4.1 but with no success.
Is there anything specifically that needs to be registered in Autofac so that return CurrentUmbracoPage() will start working again?
Not sure if the following will resolve your specific issue but a while ago I was working with Autofac and came across this sample code (can't remember original post)
//this example will put the ApplicationContext,
//all MVC controllers and API controllers in the
//current assembly in the container.
var builder = new ContainerBuilder();
builder.RegisterInstance(ApplicationContext.Current).AsSelf();
builder.RegisterControllers(Assembly.GetExecutingAssembly());
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
var container = builder.Build();
//setup the webapi dependency resolver to use autofac
var resolver = new AutofacWebApiDependencyResolver(container);
GlobalConfiguration.Configuration.DependencyResolver = resolver;
//setup the mvc dependency resolver to user autofac
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
If you haven't added that to OnApplicationStarted maybe give it a try.
Thanks for the reply, but I (unfortunately) already have that code implemented.
The site works just fine, and has for some time. But now that I started to try to use the SurfaceController with return CurrentUmbracoPage() it just doesnt work. :(
7.4.1 Surface Controller return CurrentUmbracoPage
I have a project that uses UmbracoCMS 7.4.1 with Autofac and RouteHijacking. Installed UmbracoForms last week and everything seemed fine.
But when I try to Post a form I get an error saying the /Views/UmbracoForms/Index.cshtml cannot be found. I did a test with a custom surfacecontroller
and I still get the same error like this:
I do not use any custom routes. I downloaded the UmbracoCMS source and tried debugging, and what I could see was that the controllerFactory resolves the correct controller (in UmbracoPageResult.cs) but when ExecuteControllerAction is called the ControllerContext RequestContext passed to the controller.Execute() isn't correct. The RouteData still points to UmbracoForms.
I have tried to reinstall UmbracoCMS 7.4.1 but with no success. Is there anything specifically that needs to be registered in Autofac so that return CurrentUmbracoPage() will start working again?
What I can remember it worked in 7.3.x.
Regards Martin
I should also add that I use
Hi Martin,
Not sure if the following will resolve your specific issue but a while ago I was working with Autofac and came across this sample code (can't remember original post)
If you haven't added that to OnApplicationStarted maybe give it a try.
Phill
Hi Phill,
Thanks for the reply, but I (unfortunately) already have that code implemented.
The site works just fine, and has for some time. But now that I started to try to use the SurfaceController with return CurrentUmbracoPage() it just doesnt work. :(
/Martin
is working on a reply...