C# Basic Authentication when redirecting

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?SGVybWFu?=

    C# Basic Authentication when redirecting

    My environment is as follows:

    IIS 6.0, Asp.Net 2.0, Windows 2003 Server.

    I am trying to create a single sign on SSO environment with C# and log into
    a site that is running Apache Server using basic authentication.

    Questions:

    1. How do I display the response in a new window?
    2. Is my code correct for basic authentication?

    Here's my code

    NetworkCredenti al myCred = new NetworkCredenti al("username",
    "password") ;
    CredentialCache MyCrendentialCa che = new CredentialCache ();
    MyCrendentialCa che.Add(new Uri("url"), "Basic", myCred);


    HttpWRequest.Cr edentials = MyCrendentialCa che;
    HttpWRequest.Pr eAuthenticate = true;

    HttpWRequest.Us erAgent = "CSharp HTTP Sample";
    HttpWRequest.Ke epAlive = true;
    HttpWRequest.He aders.Set("Prag ma", "no-cache");
    HttpWRequest.He aders.Add("AUTH _USER", "username") ;
    HttpWRequest.He aders.Add("AUTH _PASSWORD", "password") ;
    HttpWRequest.Al lowAutoRedirect = true;
    HttpWRequest.Ti meout = 300000;
    HttpWRequest.Me thod = "Get";


    HttpWResponse = (HttpWebRespons e)HttpWRequest. GetResponse();
    StreamReader sr = new StreamReader(Ht tpWResponse.Get ResponseStream( ),
    Encoding.ASCII) ;
    string s = sr.ReadToEnd();
    sr.Close();

    Response.Redire ct(HttpWRespons e.ResponseUri.T oString());


    thanks in advance.
Working...