authentication required popup RRS feed

  • Question

  • User1929067570 posted


    In this example i want to handle the authentication required popup from controller but it displayed: 

    var http = (HttpWebRequest)WebRequest.Create("url");
                    http.Credentials = new NetworkCredential("user", "pass", "domain");
                    var response = http.GetResponse();
                    return Redirect(response.ResponseUri.ToString());

    Why ?

    Tuesday, March 5, 2019 9:19 AM

All replies

  • User753101303 posted


    Which authentication is used by this site ?

    Tuesday, March 5, 2019 10:39 AM
  • User1929067570 posted

    It's Active Directory authentication.

    Tuesday, March 5, 2019 10:43 AM
  • User753101303 posted

    You mean Windows authentication at the IIS level or a custom form using AD behing the scene to validate the user account ? In the first case https://docs.microsoft.com/en-us/dotnet/api/system.net.networkcredential?view=netframework-4.7.2 should work (I would perhaps try against my own site it validate this). In the 2nd case you would need to POST credentials to this page so that they can process that.

    Not directly related but I always find this kind of approach a bit strange. What is the purpose of having a site in between rather than having users use directly the source site ? Especially if this is not your own, it always seems quite discutable to pretend it is your content when it is not...

    If this is your own and want to achieve some goal it might be easier to expose an API doing what you need rather than trying to reuse directly HTML pages.

    Tuesday, March 5, 2019 12:02 PM