404,当我试图从那里Azure的Web角色部署在机器打开网站 [英] 404 when I try to open the site from the machine where Azure web role is deployed

查看:107
本文介绍了404,当我试图从那里Azure的Web角色部署在机器打开网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在年底 RoleEntryPoint.OnStart()我要打开Web角色站点,以确保它不会与一些愚蠢的错误打破。所以我做以下内容:

 的WebRequest请求= WebRequest.Create(http://127.0.0.1);
使用(WebResponse类响应= request.GetResponse()){
}

和失败与引发WebException (404)未找到文本。角色对80端口开放HTTP端点,所以这不应该是一个问题。但是如果我省略code和角色开始,我可以打开 http://mysubdomain.cloudpapp.net 没有问题的。

这里有什么交易?如何从Web角色中打开Web角色网站的网页?


解决方案

您不得使用127.0.0.1,而是为WebRole指定的InputEndpoint。

您可以从中获得IPEndpoint实例一样的sode:

<$p$p><$c$c>RoleEnvironment.CurrentRoleInstance.InstanceEndpoints[\"YourInputEndpointForWebRole\"].IPEndpoint

然后您可以通过 IP地址 IPEndpoint instace。

修改

只是双重检查,以确认其原因:

这其中的原因是,该网站绑定在IIS中的网站都没有*:80(像一些在本地IIS nomrally做),但只是到该实例的具体DIP(直接(内部)IP地址)

At the end of RoleEntryPoint.OnStart() I want to open the web role site to ensure that it doesn't break with some stupid error. So I do the following:

WebRequest request = WebRequest.Create( "http://127.0.0.1" );
using( WebResponse response = request.GetResponse() ) {
}

and this fails with WebException with (404) Not Found text. The role has an open HTTP endpoint on port 80, so this should not be a problem. However if I omit that code and the role starts I can open http://mysubdomain.cloudpapp.net no problem.

What's the deal here? How do I open the web page of the web role site from within the web role?

解决方案

You shall not use 127.0.0.1, but instead the InputEndpoint specified for the WebRole.

You can get the IPEndpoint instance from it with sode like:

RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["YourInputEndpointForWebRole"].IPEndpoint

Then get the IP Address from the IPEndpoint instace.

EDIT

Just double checked to confirm the reason:

The reason for that is that the Site Bindings for the WebSite in IIS are not *:80 (like some nomrally do in local IIS) but just to the specific DIP (Direct (internal) IP Address) of the Instance.

这篇关于404,当我试图从那里Azure的Web角色部署在机器打开网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆