NullReferenceException at ServerRequestSecurityState.GetSecurityGroupsForCurrentUser(IWindowsIdentity identity) - iis-7.5

I have deployed one Lightswitch application. Details are:
Used VS2013
Have HTML Client for application
Have desktop client deployed in web for role/users/permission management
Used windows authentication and allow access to only those mentioned in aspnet provider database(desktop client)
IIS7.5
I am getting some error when I access the page, it give be below error.
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.]
Microsoft.LightSwitch.Utilities.Server.Internal.ServerRequestSecurityState.GetSecurityGroupsForCurrentUser(IWindowsIdentity identity) +56
Microsoft.LightSwitch.Utilities.Server.Internal.SecurityHelper.IsWindowsUserRegistered(IPrincipal principal, ServerRequestSecurityState state) +373
Microsoft.LightSwitch.Utilities.Server.Internal.SecurityHelper.IsUserRegistered(IPrincipal principal) +317
Microsoft.LightSwitch.Utilities.Server.Internal.SecurityHelper.AuthenticateRequest(HttpContextBase context, HttpStatusCode& status, Exception& authException) +201
Microsoft.LightSwitch.WebHost.Implementation.LightSwitchHttpModule.HandlePostAuthenticateRequest() +201
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +79
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +164
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18446
Following is the warning logged in event log.
+ System
- Provider
[ Name] ASP.NET 4.0.30319.0
- EventID 1309
[ Qualifiers] 32768
Level 3
Task 3
Keywords 0x80000000000000
- TimeCreated
[ SystemTime] 2014-08-01T15:03:43.000000000Z
EventRecordID 107901
Channel Application
Computer <DELETED>
Security
- EventData
3005
An unhandled exception has occurred.
8/1/2014 8:33:43 PM
8/1/2014 3:03:43 PM
e6e596e599ff4465968b9afeb7739958
183
58
0
/LM/W3SVC/8/ROOT-1-130513779129486922
Full
/
D:\PublishedWebsites\CustomerComplaints\
<DELEED>
8976
w3wp.exe
IIS APPPOOL\CustomerComplaints
NullReferenceException
Object reference not set to an instance of an object. at Microsoft.LightSwitch.Utilities.Server.Internal.ServerRequestSecurityState.GetSecurityGroupsForCurrentUser(IWindowsIdentity identity) at Microsoft.LightSwitch.Utilities.Server.Internal.SecurityHelper.IsWindowsUserRegistered(IPrincipal principal, ServerRequestSecurityState state) at Microsoft.LightSwitch.Utilities.Server.Internal.SecurityHelper.IsUserRegistered(IPrincipal principal) at Microsoft.LightSwitch.Utilities.Server.Internal.SecurityHelper.AuthenticateRequest(HttpContextBase context, HttpStatusCode& status, Exception& authException) at Microsoft.LightSwitch.WebHost.Implementation.LightSwitchHttpModule.HandlePostAuthenticateRequest() at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
http://<CurrentMachine>:8451/CustomerComplaints/
/CustomerComplaints/
::1
False
IIS APPPOOL\CustomerComplaints
34
IIS APPPOOL\CustomerComplaints
False
at Microsoft.LightSwitch.Utilities.Server.Internal.ServerRequestSecurityState.GetSecurityGroupsForCurrentUser(IWindowsIdentity identity) at Microsoft.LightSwitch.Utilities.Server.Internal.SecurityHelper.IsWindowsUserRegistered(IPrincipal principal, ServerRequestSecurityState state) at Microsoft.LightSwitch.Utilities.Server.Internal.SecurityHelper.IsUserRegistered(IPrincipal principal) at Microsoft.LightSwitch.Utilities.Server.Internal.SecurityHelper.AuthenticateRequest(HttpContextBase context, HttpStatusCode& status, Exception& authException) at Microsoft.LightSwitch.WebHost.Implementation.LightSwitchHttpModule.HandlePostAuthenticateRequest() at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
I believe it is something wrong with my IIS settings, but not sure. I tried to search cause and solution but not getting any clue.

Related

The IControllerFactory 'Munq.MVC.MunqControllerFactory' did not return a controller for the name 'Home'

My client has legacy application based on ASP.NET MVC 2 Framework which runs well on WinSrv 2008 R2 VM. I've cloned this machine, changed IP, hostname etc. and this cloned machine was upgraded to newest WinSrv 2019 (first 2012, then 2016 etc.). The goal was migrate this app on new server for security reason.
After migration I have noticed error which cause showing this information in browser:
error information
There is an entry in Event Viewer
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 2020-05-07 07:53:21
Event time (UTC): 2020-05-07 05:53:21
Event ID: 985ed8fb4df44033957afac395d798ea
Event sequence: 4
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/6/ROOT-1-132333044000403533
Trust level: Full
Application Virtual Path: /
Application Path: C:\websites\MY_WEBSITE.COM\www\
Machine name: WINSRV2019
Process information:
Process ID: 15700
Process name: w3wp.exe
Account name: IIS APPPOOL\MY_WEBSITE.COM
Exception information:
Exception type: InvalidOperationException
Exception message: The IControllerFactory 'Munq.MVC.MunqControllerFactory' did not return a controller for the name 'Home'.
at System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory)
at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Request information:
Request URL: https://MY_WEBSITE.COM:443/
Request path: /
User host address: MY.IP.ADDRESS
User:
Is authenticated: False
Authentication Type:
Thread account name: IIS APPPOOL\MY_WEBSITE.COM
Thread information:
Thread ID: 8
Thread account name: IIS APPPOOL\MY_WEBSITE.COM
Is impersonating: False
Stack trace: at System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory)
at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Custom event details:
This happens regularly until I refresh browser and then application works fine. I don't have access to documentation.

Azure VM MVC website unity

I have a MVC website, which using Dependency Injection "Unity", it is running fine on my local machine and also no problem on my old dedicated server (Window SEVER 2008 R2 SP1). When I move the website to Azure VM (Window SEVER 2008 R2 SP1), I got following error message;
Server Error in '/' Application.
The IControllerFactory 'Store.Factories.UnityControllerFactory' did not return a controller for the name 'Home'.
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.InvalidOperationException: The IControllerFactory 'Store.Factories.UnityControllerFactory' did not return a controller for the name 'Home'.
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:
[InvalidOperationException: The IControllerFactory 'Store.Factories.UnityControllerFactory' did not return a controller for the name 'Home'.]
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +423
System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +73
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +921
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +137
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1055.0
I cannot figure out why, Any help?
The problem was solved automatically by upgrading Unity from 2 to 4.

System.Runtime.InteropServices.COMException: Access is denied. [COMException (0x80070005): Access is denied]

I need help regarding SharePoint 2007 with windows 2008 server OS. to give you a background the server is having a trust relationship error on our domain so we need to rejoin the server to the domain. after rejoining we encounter this error and found out that the IIS Admin Services is stopped and unable to start.
here is the error:
Access is denied.
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.Runtime.InteropServices.COMException: Access is denied.
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:
[COMException (0x80070005): Access is denied.
]
System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) +557
System.DirectoryServices.DirectoryEntry.Bind() +44
System.DirectoryServices.DirectoryEntry.get_IsContainer() +42
System.DirectoryServices.ChildEnumerator..ctor(DirectoryEntry container) +36
System.DirectoryServices.DirectoryEntries.GetEnumerator() +36
Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.System.Web.IHttpModule.Init(HttpApplication app) +704
System.Web.HttpApplication.InitModulesCommon() +124
System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +1162
System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +312
System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +133
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +196

COMException Exception message: The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))

I deploy a web application in Production Server. In Production we are using Windows Server 2012, IIS 8.5. Deploying the application was successful but I got the error after 2-3 hours or 1 day from deploying the web application.
The exception is given below
**Exception information:**
**Exception type**: COMException
**Exception message:** The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.Web.Hosting.IIS7WorkerRequest.ReMapHandlerAndGetHandlerTypeString(HttpContext httpContext, String path, Boolean& handlerExists)
at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
I've tried the following:
Stop and Start IIS
Restart the Window Server
Gave enough permission in application

ACS azure for published application

Hy guys ,
I developed a WebForms application using VS 2012 . I've published it on Azure .
After that I integrated ACS ( i've set the URL to my allready published application)
I published the application again , but it doesn't work .
After I've registered myself (for ex using Yahoo or LiveID) I've got this error :
Server Error in '/' Application.
The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread's user context, which may be the case when the thread is impersonating.
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.Security.Cryptography.CryptographicException: The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread's user context, which may be the case when the thread is impersonating.
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:
[CryptographicException: The data protection operation was unsuccessful. This may have been caused by not having the user profile loaded for the current thread's user context, which may be the case when the thread is impersonating.]
System.Security.Cryptography.ProtectedData.Protect(Byte[] userData, Byte[] optionalEntropy, DataProtectionScope scope) +379
System.IdentityModel.ProtectedDataCookieTransform.Encode(Byte[] value) +52
[InvalidOperationException: ID1074: A CryptographicException occurred when attempting to encrypt the cookie using the ProtectedData API (see inner exception for details). If you are using IIS 7.5, this could be due to the loadUserProfile setting on the Application Pool being set to false. ]
System.IdentityModel.ProtectedDataCookieTransform.Encode(Byte[] value) +167
System.IdentityModel.Tokens.SessionSecurityTokenHandler.ApplyTransforms(Byte[] cookie, Boolean outbound) +57
System.IdentityModel.Tokens.SessionSecurityTokenHandler.WriteToken(XmlWriter writer, SecurityToken token) +658
System.IdentityModel.Tokens.SessionSecurityTokenHandler.WriteToken(SessionSecurityToken sessionToken) +86
System.IdentityModel.Services.SessionAuthenticationModule.WriteSessionTokenToCookie(SessionSecurityToken sessionToken) +144
System.IdentityModel.Services.SessionAuthenticationModule.AuthenticateSessionSecurityToken(SessionSecurityToken sessionToken, Boolean writeCookie) +82
System.IdentityModel.Services.WSFederationAuthenticationModule.SetPrincipalAndWriteSessionToken(SessionSecurityToken sessionToken, Boolean isSession) +216
System.IdentityModel.Services.WSFederationAuthenticationModule.SignInWithResponseMessage(HttpRequestBase request) +860
System.IdentityModel.Services.WSFederationAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs args) +369
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
What should i do ?
I've set the URL's correctly. I don't have in web.config any reffernces of "localhost"..
I don't know what I must set additionly for this to work..
By default WIF uses DPAPI to encrypt cookies. Switch to cert based encryption. See this answer:
Is it possible to run WIF without LoadUserProfile = True
Vittorio Bertocci answers the question here
http://www.cloudidentity.com/blog/2013/01/28/running-wif-based-apps-in-windows-azure-web-sites-4/
DPAPI is not available in the cloud web apps and 4.5 has a simple solutions

Resources