Copied to clipboard

Flag this post as spam?

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


  • Ryan Thomas 1 post 21 karma points
    Nov 22, 2013 @ 16:35
    Ryan Thomas
    0

    MVC Partial View Form - Null Reference Exception

    Hi I'm new to umbraco and I've been asked to help out on a project that is using it [6.1.6 I believe, using .NET 4.0 with MVC, Razor, and MiniProfiler]. I created a form following the guidelines outlined in the documentaiton here.

    The form is contained in a partial view:

    @using Project.Web.Controllers
    @using Project.Core.Models
    @model FormModel
    <div class="grid-row">
        <div class="grid-row-col grid-row-col_full mix-grid-row-col_noGutter">
            <div class="container">
                <div class="centerContain">
                    @using (Html.BeginUmbracoForm<OurSurfaceController>("SubmitThisForm")) {
                        <fieldset>
                           ... ...
                           <input type="submit" value="Submit" />
                        </fieldset>
                    }
                </div>
            </div>
        </div>
    </div>
    The form is rendered inside the page and the form model is passed in as such:
    @using Project.Web.Controllers
    @inherits UmbracoViewPage<Project.Web.Models.PageViewModel>
    @{
        Layout = "BasePage.cshtml";
    }
    @Html.Partial("Form", Model.FormModel)
     
    When the submit button on the form is submitted the following action is successfully called in the surface controller:
    public class OurSurfaceController : SurfaceController {
    
      ...
    
      [HttpPost]
      public ActionResult SubmitThisForm(FormModel model) {
          if(ModelState.IsValid) {
              // pass some information to the service layer here
          }
    
          return CurrentUmbracoPage();   
      }
    }
    
    

     

    I'm debugging the project locally and whenever I attempt to call return CurrentUmbracoPage(); get a null reference exception and a message in visual studio stating that ProfilingActionFilter.cs could not be found. I tried the solutions contained in this forum post, read this forum post, and trying searching via google for help but I'm coming up blank.

    Here is the stack trace. I'd appreciate any help. Thanks!

    [NullReferenceException: Object reference not set to an instance of an object.]
       StackExchange.Profiling.MVCHelpers.ProfilingActionFilter.OnActionExecuting(ActionExecutingContext filterContext) in c:\Code\github\SamSaffron\MiniProfiler\StackExchange.Profiling\MVCHelpers\ProfilingActionFilter.cs:40
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +41
       System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +21
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +253
       System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +21
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
       System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +324
       System.Web.Mvc.Controller.ExecuteCore() +106
       System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +91
       System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
       Umbraco.Web.Mvc.UmbracoPageResult.ExecuteResult(ControllerContext context) +1054
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
       System.Web.Mvc.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() +23
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +242
       System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +21
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +242
       System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +21
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +242
       System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +21
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
       System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +324
       System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__19() +23
       System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +19
       System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10
       System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
       System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +57
       System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
       System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
       System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +47
       System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
       System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +25
       System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +23
       System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
       System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +47
       System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9628972
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
Please Sign in or register to post replies

Write your reply to:

Draft