before i didnt have this problem, i updated my windows from 7 to 10 , and then installed sql server 2012 and vs 2012. now i open my project and see this error message in site.master. how can i fix this problem ?? thank you
protected void master_Page_PreLoad(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Set Anti-XSRF token
ViewState[AntiXsrfTokenKey] = Page.ViewStateUserKey;
ViewState[AntiXsrfUserNameKey] = Context.User.Identity.Name ?? String.Empty;
}
else
{
// Validate the Anti-XSRF token
if ((string)ViewState[AntiXsrfTokenKey] != _antiXsrfTokenValue
|| (string)ViewState[AntiXsrfUserNameKey] != (Context.User.Identity.Name ?? String.Empty))
{
throw new InvalidOperationException("Validation of Anti-XSRF token failed.");
}
}
}
i see error on this line:
ViewState[AntiXsrfUserNameKey] = Context.User.Identity.Name ?? String.Empty;
here is exception details:
System.NullReferenceException was unhandled by user code
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=App_Web_iq1yfyyi
StackTrace:
at Site.master_Page_PreLoad(Object sender, EventArgs e) in e:\Asp.Net projects\Basije daneshgah marvdasht\Site.master.cs:line 56
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Web.UI.Page.OnPreLoad(EventArgs e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException: