I am receiving the following error when I try to navigate to a website I have deployed to the production machine.
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:
[No relevant source lines]
Source File: c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\application portal\b63251b4\7eccc081\App_Web_t1vvgyvo.1.cs Line: 0
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
ASP._Page_Views_NewHire_NewEmpForm_cshtml.Execute() in c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\application portal\b63251b4\7eccc081\App_Web_t1vvgyvo.1.cs:0
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +279
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +125
System.Web.WebPages.StartPage.ExecutePageHierarchy() +142
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +109
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +379
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +108
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +890
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +97
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +241
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +19
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +51
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
Now the basic error (Object reference not set..) is something I have encountered before. What has me stumped is the "No relevant source lines" and the fact that the Source File of the error is a temporary one.
I would greatly appreciate any suggestions as to what the issue might be.
EDITS BELOW
The View that should be loading:
@model Application_Portal.Models.Employee
<h2> New Employee Data Information</h2>
<form class="form-horizontal" method="post" id='newHireForm' action="NewEmpForm">
<input type="hidden" name="EmployeeID" value="@Model.EmployeeID" />
<div class="form-group">
<label class="control-label col-md-2">First Name: </label><div class='col-md-4'><input type='text' class='form-control' readonly value='@Model.FirstName' /></div>
<label class="control-label col-md-2">Last Name: </label><div class='col-md-4'><input type='text' class='form-control' readonly value='@Model.LastName' /></div>
</div>
<div class="form-group">
<label class="control-label col-md-2">Full SSN: </label><div class='col-md-4'><input type='password' class='form-control' name="SSN" id="SSN" /></div>
<label class="control-label col-md-2">Confirm SSN: </label><div class='col-md-4'><input type='password' class='form-control' id="SSNConfirm" /></div>
</div>
<div class="form-group">
<label class="control-label col-md-2">Date of Birth: </label><div class='col-md-4'><input type='text' class='form-control' name="DOB" /></div>
</div>
<div class="form-group">
<label class="control-label col-md-2">Phone: </label><div class='col-md-4'><input type='text' class='form-control' readonly value='@Model.Phone' /></div>
<label class="control-label col-md-2">Cell Phone: </label><div class='col-md-4'><input type='text' class='form-control' readonly value='@Model.CellPhone' /></div>
</div>
<div class="form-group">
<label class="control-label col-md-2">Street Address: </label><div class='col-md-4'><input type='text' class='form-control' readonly value='@Model.StreetAddress' /></div>
<label class="control-label col-md-2">City: </label><div class='col-md-4'><input type='text' class='form-control' readonly value='@Model.Applicant.City' /></div>
</div>
<div class="form-group">
<label class="control-label col-md-2">State: </label><div class='col-md-4'><input type='text' class='form-control' readonly value='@Model.Applicant.State' /></div>
<label class="control-label col-md-2">Zip: </label><div class='col-md-4'><input type='text' class='form-control' readonly value='@Model.Applicant.Zip' /></div>
</div>
<div class="form-group">
<label class="control-label col-md-2">Marital Status: </label><div class='col-md-4'><input type='text' class='form-control' name="MaritalStatus" /></div>
<label class="control-label col-md-2">Gender: </label><div class='col-md-4'><select class='form-control' name="Sex"><option value="M">Male</option><option value="F">Female</option></select></div>
</div>
<div class="form-group">
<label class="control-label col-md-2">Race: </label><div class="col-md-4">
<select class='form-control' name='Race'>
<option value="White">White</option>
<option value="Black">Black</option>
<option value="Hispanic">Hispanic</option>
<option value="Asian">Asian or Pacific Islander</option>
<option value="Native">American Indian or Alaskan Native</option>
</select>
</div>
<label class="control-label col-md-2">Residency: </label><div class='col-md-4'><select class='form-control' name="Residency"><option value="Citizen">Citizen or National of the United States</option><option value="Lawful Permanent Resident">Lawful Permanent Resident</option><option value='Authorized Alien'>Authorized Alien</option></select></div>
</div>
<div class="form-group">
<label class="control-label col-md-2">Alien # or Admission # (optional): </label><div class="col-md-4">
<input type="text" class='form-control' name='AlienNumber' />
</div>
</div>
<input type="submit" value="Submit" name="applicationSubmit" id="applicationSubmit" class="btn btn-primary pull-right" />
</form>
This is the controller/view combination that is giving me trouble:
[Authorize]
[NewHireFilter]
public ActionResult NewEmpForm()
{
HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);
Int32 newHireID = Convert.ToInt32(ticket.Name);
Employee newEmp;
newEmp = dbContext.Employees.FirstOrDefault(e => e.EmployeeID == newHireID);
return View(newEmp);
}
However, this one works just fine:
[Authorize]
[NewHireFilter]
public ActionResult ModuleOne()
{
ModuleOneViewModel vm = new ModuleOneViewModel();
HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);
Int32 newHireID = Convert.ToInt32(ticket.Name);
vm.newHire = dbContext.Employees.FirstOrDefault(e => e.EmployeeID == newHireID);
return View(vm);
}
Again, I would really appreciate any help as this is a perplexing issue to me.
Thanks.