私はWCFウェブサイトを使用しようとしていますが、これはsiteminderで保護されています。問題は、ブラウザでWebサービスのURLを参照しようとしているときに、私が提供している認証情報で正常に動作していることです。WCFサービスでsiteminderが保護されている。C#
しかし、プログラムで同じことをしようとすると、エラー# #401が不正になりました。参照用
- http://www.codeproject.com/Articles/80314/How-to-Connect-to-a-SiteMinder-Protected-Resource
CookieContainer cookies = null;
HttpWebRequest request = null;
HttpWebResponse response = null;
string responseString = null;
NameValueCollection tags = null;
string url = null;
url = PROTECTED_URL;
Debug.WriteLine("Step 1: Requesting page @" + url);
request = (HttpWebRequest)WebRequest.Create(url);
request.AllowAutoRedirect = false;
response = (HttpWebResponse)request.GetResponse();
ShowResponse(response);
// Step 2: Get the redirection location
// make sure we have a valid response
if (response.StatusCode != HttpStatusCode.Found)
{
throw new ApplicationException();
}
url = response.Headers["Location"];
// Step 3: Open a connection to the redirect and load the login form,
// from this screen we will capture the required form fields.
Debug.WriteLine("Step 3: Requesting page @" + url);
request = (HttpWebRequest)WebRequest.Create(url);
request.AllowAutoRedirect = false;
try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (Exception ex)
{
string str = ex.Message.ToString();
}
したがって、ブラウザからサンプルメソッドを呼び出すと、正常に動作しますが、同じメソッドをプログラムで呼び出すと、正しく動作しません。最初にコードを表示します。 –
私は自分の資格情報でURLをヒットしたときに問題なく動作していますが、プログラムで応答を得ようとしているときにエラー –
が表示されます。どのようにそれを取得しようとする –