Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Roger Withnell 128 posts 613 karma points
    Jun 06, 2015 @ 21:40
    Roger Withnell
    0

    TempData causes an error

    I've set up a SurfaceController as per Umbraco.tv (excellent) and it works fine until I add the code in "The finishing touches". When I add the code to display a message after the contact form is submitted I get an error. The code I add to the ContactFormViewModel that causes the error is: @if (TempData["success"] == null) {....

    The error occurs on the PartialView Macro page at: @Html.Action("Index", "ContactFormSurface")

    and the error detail is: System.Web.HttpException was unhandled by user code HResult=-2147467259 Message=Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'. Source=System.Web ErrorCode=-2147467259 WebEventCode=0 StackTrace: at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage) at System.Web.HttpServerUtility.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) at System.Web.HttpServerUtilityWrapper.Execute(IHttpHandler handler, TextWriter writer, Boolean preserveForm) at System.Web.Mvc.Html.ChildActionExtensions.ActionHelper(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues, TextWriter textWriter) at System.Web.Mvc.Html.ChildActionExtensions.Action(HtmlHelper htmlHelper, String actionName, String controllerName, RouteValueDictionary routeValues) at System.Web.Mvc.Html.ChildActionExtensions.Action(HtmlHelper htmlHelper, String actionName, String controllerName) at ASP.PageViewsMacroPartialsContactFormcshtml.Execute() in c:\Users\roger000\Documents\Visual Studio 2013\Projects\ParishMaster\ParishMaster\Views\MacroPartials\ContactForm.cshtml:line 4 at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.Mvc.WebViewPage.ExecutePageHierarchy() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) at Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer) at Umbraco.Web.Mvc.ControllerExtensions.RenderViewResultAsString(ControllerBase controller, ViewResultBase viewResult) at Umbraco.Web.Macros.PartialViewMacroEngine.Execute(MacroModel macro, IPublishedContent content) at Umbraco.Web.Macros.PartialViewMacroEngine.Execute(MacroModel macro, INode node) at umbraco.macro.LoadPartialViewMacro(MacroModel macro) at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId) InnerException: System.Web.HttpParseException HResult=-2147467259 Message=Unexpected "using" keyword after "@" character. Once inside code, you do not need to prefix constructs like "using" with "@".

       Source=System.Web.WebPages.Razor
       ErrorCode=-2147467259
       WebEventCode=0
       FileName=C:\Users\roger_000\Documents\Visual Studio 2013\Projects\ParishMaster\ParishMaster\Views\Partials\ContactForm.cshtml
       Line=5
       VirtualPath=/Views/Partials/ContactForm.cshtml
       StackTrace:
            at System.Web.WebPages.Razor.RazorBuildProvider.EnsureGeneratedCode()
            at System.Web.WebPages.Razor.RazorBuildProvider.get_CodeCompilerType()
            at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider)
            at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()
            at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()
            at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
            at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
            at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
            at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)
            at System.Web.Compilation.BuildManager.GetCompiledType(VirtualPath virtualPath)
            at System.Web.Compilation.BuildManager.GetCompiledType(String virtualPath)
            at System.Web.Mvc.BuildManagerWrapper.System.Web.Mvc.IBuildManager.GetCompiledType(String virtualPath)
            at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
            at Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer)
            at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
            at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(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.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
            at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
            at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
            at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
            at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
            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.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
            at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
            at System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag)
            at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
            at System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller)
            at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
            at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
            at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
            at System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag)
            at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
            at System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.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.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
            at System.Web.Mvc.Async.AsyncResultWrapper.End[TResult](IAsyncResult asyncResult, Object tag)
            at System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag)
            at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
            at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
            at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerAsyncWrapper.<>c__DisplayClassa.<EndProcessRequest>b__9()
            at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.<>c__DisplayClass4.<Wrap>b__3()
            at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.Wrap[TResult](Func`1 func)
            at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.Wrap(Action action)
            at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerAsyncWrapper.EndProcessRequest(IAsyncResult result)
            at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
       InnerException:
    

    What am I doing wrong?

    Your help would be much appreciated.

    Thanking you in anticipation.

    Roger

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    Jun 07, 2015 @ 10:16
    Sebastiaan Janssen
    100

    It looks like the error is actually this:

    Unexpected "using" keyword after "@" character. Once inside code, you do not need to prefix constructs like "using" with "@".

    So somewhere in your code you're in a C# block and used an @ sign, which you can't do as you are already in C#-mode. If you show some of your code we can spot the error.

Please Sign in or register to post replies

Write your reply to:

Draft