Null reference error on Umbraco.Web.UmbracoModule.BeginRequest
I've just completed a clean install of Windows 8.1 and running a site from Visual Studio and IIS Express I can't load the site due to a null reference error on what looks to be the httpcontext. I'm running out of ideas now but think its something to do with .net early in the lifecycle as Visual Studio doesn't break into the exception:
[NullReferenceException: Object reference not set to an instance of an object.]
Umbraco.Web.UmbracoModule.BeginRequest(HttpContextBase httpContext) +13
Umbraco.Web.UmbracoModule.<Init>b__5(Object sender, EventArgs e) +253
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
Same error when trying to access anything including ~/umbraco. I created another bare bones site with a clean install of Umbraco and I don't have any problems which is not what I expected but might rule out anything to do with the .Net Framework or MVC.
Sounds like a missing global.asax file.. I've seen this before and I can't figure out how to fix it, I'm assuming you have VS13 and did file > new project and installed the Umbraco NuGet package? The only thing that helps for me is to close the solution, open it again and then it works. It's super annoying and I couldn't find any file changes between before closing the solution and afterwards.
Thanks Sebastiaan, it was the Global.asax file which strangely was missing. Having looked back at the commit logs somebody had removed it from the solution so I am going to hunt them down now and give'em a slap!
I get the same error. Opening and closing does not work for me.
When I set a breakpoint on the global file it does break and I can step through but as soon as the debugger exits I receive the error
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;
namespace u616Bootstrap3
{
// Note: For instructions on enabling IIS6 or IIS7 classic mode,
// visit http://go.microsoft.com/?LinkId=9394801
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
}
}
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
Umbraco.Web.UmbracoModule.BeginRequest(HttpContextBase httpContext) +58
Umbraco.Web.UmbracoModule.<Init>b__5(Object sender, EventArgs e) +320
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18446
You need to remove global.asax.cs, Umbraco's Umbraco.Web.UmbracoApplication needs to kick in, which is prevented if the global.asax.cs exists. Make sure to rebuild after removing the .cs file.
Null reference error on Umbraco.Web.UmbracoModule.BeginRequest
I've just completed a clean install of Windows 8.1 and running a site from Visual Studio and IIS Express I can't load the site due to a null reference error on what looks to be the httpcontext. I'm running out of ideas now but think its something to do with .net early in the lifecycle as Visual Studio doesn't break into the exception:
Any ideas on what the cause/solution is?
Cheers, Simon
Hi Simon,
Do you have any content? if so have you tried to republish entire site? do you ave access to Umbraco or you get the same error?
Cheers
Ali
Same error when trying to access anything including ~/umbraco. I created another bare bones site with a clean install of Umbraco and I don't have any problems which is not what I expected but might rule out anything to do with the .Net Framework or MVC.
Simon
Sounds like a missing global.asax file.. I've seen this before and I can't figure out how to fix it, I'm assuming you have VS13 and did file > new project and installed the Umbraco NuGet package? The only thing that helps for me is to close the solution, open it again and then it works. It's super annoying and I couldn't find any file changes between before closing the solution and afterwards.
Thanks Sebastiaan, it was the Global.asax file which strangely was missing. Having looked back at the commit logs somebody had removed it from the solution so I am going to hunt them down now and give'em a slap!
Cheers, Simon
Hi
I get the same error. Opening and closing does not work for me.
When I set a breakpoint on the global file it does break and I can step through but as soon as the debugger exits I receive the error
You need to remove global.asax.cs, Umbraco's
Umbraco.Web.UmbracoApplication
needs to kick in, which is prevented if the global.asax.cs exists. Make sure to rebuild after removing the .cs file.Thank you.
But how do I then, for example, register bundles to the bundletable?
Ok. I found the answer
http://our.umbraco.org/Documentation/Reference/Events/application-startup
As others said, it is due to the Global.asax file. you can solve this by adapting below approach.
1. Delete Global.asax.cs file from the solution.
2. Change the Mark up code for Global.ASAX file to
<%@ Application Codebehind="Global.asax.cs" Inherits="Umbraco.Web.UmbracoApplication" Language="C#" %>
Thank you,
Amrut
is working on a reply...