【发布时间】:2015-03-03 15:37:58
【问题描述】:
所以我有一个包含唯一页面的小型 asp.net 应用程序。
它是来自 Page_Load 方法的代码(它只是代码隐藏中的代码):
string url = "https://api.vkontakte.ru/oauth/access_token?client_id=123&client_secret=123&code=123&redirect_uri=mysite.com";
var webRequest = (HttpWebRequest)WebRequest.Create(url);
/*
if i comment this line
i get exception an exception with following message
The remote server returned an error: (407) Proxy Authentication Required
*/
webRequest.Proxy = null;
using (var response = (HttpWebResponse)webRequest.GetResponse()) //
{
using (var reader = new StreamReader(response.GetResponseStream()))
{
string str = reader.ReadToEnd();
TokenBox.Text = str;
}
}
那么我的问题是什么?此应用程序部署在 iis 7.5 中。当我将它作为 iis 站点时,我收到异常 WebException 并显示消息“无法连接到远程服务器”。但是,如果我在 Visual Studio 中按 F5 按钮并使用 IIS Express 调试我的 Web 应用程序,则此代码可以正常工作。 这种奇怪行为的原因是什么?如何修复它并使我的应用程序从 IIS 站点正常工作?
【问题讨论】:
-
测试IIS网站和调试是否使用同一个浏览器?
-
两种方法都试了,结果一样
标签: asp.net iis iis-express