Allow Console App to Access Windows Authenticated Web App
I have an MVC web application using Windows Authentication. So we do things likeSystem.Web.HttpContext.Current.User.Identity.Name
There is now a console application that I am writing that will run as part of a batch job. All this console application needs to be done is invoke ActionResult
in the main web application, which will then perform some maintenance tasks.
Now, since the console application has no ID in the domain controller / Active Directory, the call using System.Net.WebClient().DownloadString()
continues to throw a 401 error.
My question is, is there a way to allow this application to call this link in the main web application without disabling WindowsAuthentication in web.config / IIS?
Any ideas / suggestions are greatly appreciated.
The entire console application contains
static void Main(string[] args)
{
try
{
new System.Net.WebClient().DownloadString(System.Configuration.ConfigurationSettings.AppSettings["http://foo.com/"]);
}
catch
{
}
}
source to share