.Net Application logs out on certain pages - c#

I have a .Net website and when I click the menu for certain pages I am automatically logged out. I tried debugging by opening code and hooking up to the environment database but I am able to open the pages locally. I am not sure why this is the case.
I would like some input about where to start troubleshooting.

I would first check if the server is faulting and losing the session somehow. Perhaps the worker process is crashing or the application pool is recycling for some reason. Without more information this is just a guess though.

Related

Auto restart IIS Website from console application

We have an ASP.Net application used by many customers installed on their own servers. Because it is installed on their end with each having different databases and URL bindings etc I created a console application a while ago that gets a zip file and extracts it to c:\inetpub location to append the latest application changes. This console app is added to scheduled tasks to create an automated update.
Obviously when anyone accesses the site for the first time after it does this they have to wait a little longer whilst the site rebuilds. I changed the console application to include a Process.Start(urlofapp) so that it should hopefully do this as part of the update so the next morning that first user doesn't have to wait for the rebuild.
I have tested it ok running myself but not yet released as my concern is that this url process is kept open. Can anyone enlighten me as to whether this would be the case as I don't want this to happen or can give me any ideas as to how to rebuild the site manually as part of the console app.
IIS has had an auto-start apps feature for quite some time. You just have to enable it. You can find more info from the Gu, and the IIS site.
Safer instead to use a start page which loads everything on the server in the background. If you do this logic in an async method which in turn is called from an MVC controller for example then this can potentially run whilst the main page has finished. Alternatively use a threaded Task and show a start page that is only returned whilst setup is taking place.

ClrMD on another user's process

I have a .Net application that's reporting hangs in the Event Log. The events say "Application Hang" with no usable details to go by.
So I whipped up a C# console app that uses the ClrMD library. But the caveat is this application is being published as a RemoteApp. When I try to attach ClrMD to the users' process I get this error:
Microsoft.Diagnostics.Runtime.ClrDiagnosticsException: Could not attach to process. Error 0.
This is not surprising since I'm logged into the server as Administrator and they are in their own RDP session with a different user.
So then I decided to impersonate the user they are logged in as thinking if I run my ClrMD app as them, it will have access to that process. This gave me a different error:
Microsoft.Diagnostics.Runtime.ClrDiagnosticsException: Could not attach to process. Error 1008.
I can't seem to find any clues as to what 1008 means to know where to go from here. I realize I'm probably trying to do something that's not possible.
Has anyone gotten ClrMD to attach to another user's process?
If not, are there are debug tools out there that can attach to other users' processes?
If not, have people used ClrMD in within production and how would I know the app is hung to know when to trigger a ClrMD dump? Just monitor the UI thread in another background thread?
Had / have same issue. Running elevated as admin on a server via a console app didn't work. But it does work if run through PowerShell or Visual Studio itself with elevated permissions. The debugger requires Admin privs to connect live. Adding a manifest, etc didn't seem to help when running as a console.

Debugging C# MVC3 in visual studio : can i stop session data from clearing each time i re-start debugging?

Each time when I stop debugging on localhost and start again, session data gets cleared. So, I have to log- out and log-in again to reach same point. This has become a pain because I have to go through the whole log-in process to reach the page that I was working on.
Any help on this is much appreciated.
If you're using InProc session state management (the default), then you're going to be out of luck. Whenever the IIS worker process restarts (when you start debugging), the session state is cleared. The advantage to InProc, of course, is that it runs in memory, so it's faster.
However, you could switch to using a state server or a database to manage the sessions. Those both run out-of-process, meaning they don't get cleared when IIS restarts, or when you start debugging.
See This Microsoft article for setting up a state server to manage sessions.
See This Microsoft article for setting up a SQL server for managing sessions.
Or perhaps, an alternative could be to use the #if DEBUG directive to hard-code and pre-populate a username and password during the login process? That could at least save typing time :)

ASP.net Web Application Pages Stop Responding (Web Forms) on IIS 8

Well, we have an web application deployed on:
Windows Server 2012
IIS 8.​
Target .net Framework 4.0
DevExpress Ver: 13.1.8 (third-party controls)
Now the issue is this, some of the pages stop responding when we try to load them. (after few time- not specific)
To make them in working again we have to restart 'World Wide Web Publishing Service' or sometime 'IIS' as well.
But after few hours, again the pages stop responding. Browser does't even give any error message, just keep trying
to load page and go in 'Waiting for Server Response' state.
And this behavior is not for all page. Even under this scenario some other pages still work. It means application is running
but some pages are note working.
I have also check that there is no dead lock at database level.
Also, IIS 8 is enable with both 3.5 and 4.5 options.
Note: We have some other applications on the same server running fine.
Can you please suggest me that how can I resolve this issue,
Thanks
Qazi
​
I suggest to create a Hello World! page and load it.
If the Hello World page even doesn't load, analyse the IIS log .
especially look at the value of "Win32Status" . If its not 0, use - net helpmsg [Win32StatusCode] in command line . This should give you enough clue for troubleshooting.
I suspect it is the HTTP Compression that is causing the issue; dump the HTTP Compression in Web Extensions, and then it will behave better.
Check also your CPU and RAM workload.

Trying to display a GUI in Session 0

I have searched everywhere and tried just about everything and I am starting to think this is not possible.
I have a service running in Session 0 (win7) as SYSTEM.I need to launch an external application. If I simply launch the external application as SYSTEM, the application launches and I can see the GUI (if I click over to Session 0 using UI0Detect). In addition to me being able to see it, my service that launched the application can actually take a screen shot of the GUI and send it back to my servers. - at this point all is good.
The issue - there are cases where the external application is not allowed to run under the SYSTEM context. In these cases I must launch as a different user. I have another service running as an actual user in Session 0. I then launch the external application as this other user. The external application is launched in Session 0, and I specify WinSta0\Default to ensure that the application GUI launches on the same desktop that my SYSTEM service can see. When this happens UI0Detect pops up giving me the impression that i will click over and see my window. When I get over to session 0 or when my service attempts a screen shot, there is just a small black box. It's almost like only the SYSTEM account can render windows in session 0 - is this true? anyone know if user accounts running in session 0 are able to render a GUI?
I am not looking for code on how to launch an application from session 0 to an active user desktop. That is well documented. What I need to know is how to pull off the reverse (sort of). I need to launch a GUI in session 0 from an account other than SYSTEM.
From MSDN: "If the service type specifies SERVICE_INTERACTIVE_PROCESS, the service must run in the LocalSystem account."
So there is no supported way to do what you're trying to do. However, it might be possible to get it to work by getting the service that runs as SYSTEM to change the permissions on the desktop (and perhaps the window station) in question. Keep in mind that sharing a desktop in this way means that if the application or the user account in question is compromised, it may be able to compromise the system account.
Alternatively, you could try creating a new desktop in session 0 (with appropriate permissions) and launching the application there. I'm not sure if the interactive user would be able to see this desktop, but you could take a screenshot by launching another application in the same desktop (and preferably in the same user context) to take the screenshot on your behalf.

Categories