This is a very common error while working on Razor application very first time.
To fix this issue add the reference of
using System.Web.WebPages.Scope;
using System.Reflection;
and then add the below event in Global.asax
protected void Application_BeginRequest()
{
var ob = typeof(
AspNetRequestScopeStorageProvider).Assembly.GetType(
"System.Web.WebPages.WebPageHttpModule").GetProperty
("AppStartExecuteCompleted",
BindingFlags.NonPublic | BindingFlags.Static);
ob.SetValue(null, true, null);
}