Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/315.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 启用Windows身份验证的IIS站点使用两种不同的绑定执行不同的操作_C#_Asp.net_Iis - Fatal编程技术网

C# 启用Windows身份验证的IIS站点使用两种不同的绑定执行不同的操作

C# 启用Windows身份验证的IIS站点使用两种不同的绑定执行不同的操作,c#,asp.net,iis,C#,Asp.net,Iis,我在IIS 7中设置了一个站点,它使用Windows身份验证作为唯一启用的身份验证模式。它使用自定义的.NET 4应用程序池-该池使用默认的ApplicationPoolIdentity。此网站是一个C#/ASP.NET应用程序,具有自己的页面授权规则(使用Iron Speed Designer 9生成)。我在下面设置了两个绑定: serviceditory.sampledomain.com booking.sampledomain.com 这两个绑定都映射到端口80上所有可用IP上的站点 在大

我在IIS 7中设置了一个站点,它使用Windows身份验证作为唯一启用的身份验证模式。它使用自定义的.NET 4应用程序池-该池使用默认的ApplicationPoolIdentity。此网站是一个C#/ASP.NET应用程序,具有自己的页面授权规则(使用Iron Speed Designer 9生成)。我在下面设置了两个绑定:

serviceditory.sampledomain.com

booking.sampledomain.com

这两个绑定都映射到端口80上所有可用IP上的站点

在大多数情况下,浏览任何一个绑定都可以成功地工作,但在某个页面中,我创建了一个WebRequest以流的形式获取另一个页面。(我正在将另一页的内容作为附件嵌入到iCal(.ics)文件中,以便包含在会议请求中。该文件由用户下载并发送)

问题如下:当用户在第一个绑定(serviceditory.sampledomain.com)下浏览时,此代码成功并将Confirmation.aspx页面中的内容作为字符串数据(attachmentContent变量)生成。但是,我在
WebResponse-WebResponse=webRequest.GetResponse()处得到了一个401.1错误行。应用程序源代码或web.config中没有对这两个绑定的引用-所有内容都是为了部署到任何URL而构建的

为什么两个不同的绑定会影响这一点

String request = Request.Url.GetLeftPart(UriPartial.Path).
    Replace("Conference.aspx", "Confirmation.aspx") +
    "?Conference=" + conference.ConferenceId;
WebRequest webRequest = WebRequest.Create(request);
webRequest.UseDefaultCredentials = true;

webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
Stream newStream = webRequest.GetRequestStream();
// Send the data.
newStream.Close();
WebResponse webResponse = webRequest.GetResponse();

Stream responseStream = webResponse.GetResponseStream();
using (MemoryStream ms = new MemoryStream())
{
    responseStream.CopyTo(ms);
    attachmentContent = Convert.ToBase64String(ms.ToArray());
}

responseStream.Close();