I am developing a portal in C # MVC3 and in a given operation I need to open another window in a separate window. To open the page of this new portal I need to send some credentials, since it is implemented with basic authentication.
I'd like to know how I can do it. I already tried controller
:
var request = (HttpWebRequest)WebRequest.Create(redirectUrl);
request.Method = "GET";
request.UseDefaultCredentials = false;
request.PreAuthenticate = true;
var cred = new NetworkCredential("user1", "pass123");
var cache = new CredentialCache();
cache.Add(new Uri(redirectUrl), "Basic", cred);
request.Credentials = cache;
var response = (HttpWebResponse) request.GetResponse();
return Redirect(response.ResponseUri.ToString());
What is the best way to do this?