【问题标题】:difference between launch site from iis and iis expressiis 和 iis express 的发射站点之间的区别
【发布时间】: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 站点正常工作?

【问题讨论】:

标签: asp.net iis iis-express


【解决方案1】:

https://blog.lextudio.com/2015/04/web-application-differences-in-visual-studio-and-iis/

要发出请求,.NET/Windows 需要适当的网络设置(例如代理、身份验证等),您的帐户可能可以在 VS 中运行代码。但是,IIS 显然不能保证代码能够正常工作,因为您尚未使用相同的网络设置设置应用程序池标识。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-10-30
    • 1970-01-01
    • 2010-10-14
    • 1970-01-01
    • 1970-01-01
    • 2014-05-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多