I have a website that I publish in Visual Studio 2008 and then send off to other people. One of the pages needs to alter a few configuration files, so an action is executed using WindowsImpersonationContext inside a class library referenced by the website.
protected void WithImpersonation(ExecuteUnderImpersonation action)
{
using(WindowsImpersonationContext context = Request.LogonUserIdentity.Impersonate())
{
action();
}
}
However when someone else tries to submit this page, it throws an error that it was
Unable to save config to file 'C:\Inetpub\wwwroot\SomeWebsite\web.config'.
Looking at the StackTrace I see this entry:
at SomeClassLibrary.SomeClass.WithImpersonation(ExecuteUnderImpersonation action) in FILEPATH FROM MY MACHINE:line 23
This appears to be happening on only one specific page, even though multiple pages call this same method.
If I've published the website (in Updatable mode) to the PrecompiledWeb folder, and released it with the appropriate references in the bin directory, why does it look for the class on my machine? The error doesn't even make sense, if its looking for a file that doesn't exist on their server, shouldn't they be getting a much different error?
I took the same website and put it up on one of my servers connected to the domain. If I tried running that same page from the server logged in as myself, or on my machine, I don't receive this error.
A coworker has said before that they also receive this error sometimes, but that it eventually goes away. We can't pinpoint the cause of the issue, but if the same website were to be checked out of SVN on someone elses computer, published, and then sent off, this error doesn't happen at all.
Any ideas as to what is going on?