Copied to clipboard

Flag this post as spam?

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


  • marcelh 171 posts 471 karma points
    May 29, 2018 @ 20:06
    marcelh
    0

    Error parsing record with Razor view, System.ArgumentException: Value does not fall within the expected range

    On a website, a user has the possibility to register for a stock notification for a product that is currently out of stock. An UmbracoForms form is used for this, that gets the Submitted state when a user submits the form. An workflow is setup, that when the form gets the Approved state a razor e-mail is sent out to the registered user. When the form is manually approved, all is fine and the email is sent out correctly.

    However, life is not that simple. We're using the CMS Import package that bulkimports the products. An eventhandler is setup for ContentService.Published that detects when a Product that is published has become available again. When a product is available, the corresponding form gets the Approved state, which causes the email to be sent automatically.

    Now, when manually running the import the email is sent out correctly. However, when scheduled and run outside the Umbraco Backoffice context, sending the email fails with the following exception and stacktrace:

        2018-05-29 21:07:20,444 [P21664/D3/T87] ERROR Umbraco.Forms.Core.Record - Error parsing record with Razor view
    System.ArgumentException: Value does not fall within the expected range.
       at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
       at System.Web.Hosting.IIS7WorkerRequest.GetServerVariableInternal(String name)
       at System.Web.HttpWorkerRequest.IsLocal()
       at System.Web.HttpRequestWrapper.get_IsLocal()
       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 Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer)
       at Umbraco.Web.Mvc.ControllerExtensions.RenderViewToString(ControllerBase controller, String viewName, Object model, Boolean isPartial)
       at Umbraco.Forms.Core.Record.ParseWithRazorView(String razorViewFilePath)
    

    When I research this message, it is stated that this can be caused by a missing HttpContext.Current. However, when inspecting the source of UmbracoForms, both a missing HttpContext and UmbracoContext are guarded and this throws no exception in the process. So this seems to be caused by something else.

    By not using a Razor e-mail but using a text e-mail instead, the mail is correctly sent out, so it appears that the razor rendering does something special here... Any clues?

Please Sign in or register to post replies

Write your reply to:

Draft