Reputation: 59
I'm going a bit crazy.
I have a legacy WebForms app, .NET 4.8. Application uses Windows Authentication (corporate network), with Anonymous turned off.
I want to, from with in my code, hit a URL (in the same application no less), get the results, then send those results to my PDF maker.
Problem. On my local, I can get my code to run and work as "DOMAIN\MyUser", which is what I want. But as soon as I deploy to our DEV Server, it is all going in as anonymous (I look at IIS Log Files), which of course doesn't work.
I tried a bunch of ways using WebClient, then tried HttpClient because I guess WebClient is obsolete, but I actually had better results with WebClient.
This is just one example of my code:
var wi = ( WindowsIdentity )Thread.CurrentPrincipal.Identity;
var wic = wi.Impersonate();
try {
using ( var client = new WebClient { UseDefaultCredentials = true } ) {
resultStr = client.DownloadString( url );
}
}
catch ( Exception ex ) {
System.Diagnostics.Debug.WriteLine( ex.ToString() );
}
finally {
wic.Undo();
}
I have other samples, none of which do what I need.
Could this be not a code problem, but a server configuration problem?
Upvotes: 0
Views: 33