【发布时间】:2015-10-19 12:19:07
【问题描述】:
我正在编写一个C# 应用程序来从 URL 获取一些信息。
网址是 Web 应用程序,托管在我们本地 intranet 环境中的 IIS 中。
Web 应用程序是使用 ASP.NET (C#) 开发的。
在 IIS 中,这些配置为 Forms 或 Windows 身份验证。
有没有办法识别对应的web应用url是什么类型的认证?
这是我目前得到的!
using System;
using System.IO;
using System.Net;
public class Program
{
public static void Main()
{
var url = "http://www.contoso.com/default.html";
WebRequest request = WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse ();
//he i need to know what type of authentication the url
Console.WriteLine (response.StatusDescription);
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader (dataStream);
string responseFromServer = reader.ReadToEnd();
reader.Close ();
dataStream.Close ();
response.Close ();
}
}
【问题讨论】:
标签: c# asp.net .net iis console-application