【发布时间】:2017-03-24 20:01:36
【问题描述】:
我有一个托管在 ASP.NET Web 应用程序中的 WCF 服务,在 Azure 中作为应用服务运行。
当我在本地机器上运行这个项目时没有错误。但是当部署到 Azure 时,出现以下错误:
[AddressAccessDeniedException: HTTP 无法注册 URL http://+:80/docs/。您的进程没有访问权限 命名空间(参见http://go.microsoft.com/fwlink/?LinkId=70353 详情)。]
关于本地机器的这个错误有很多帖子,但与 azure 无关。 Theu 建议运行 netsh 以授予 url 权限,但我不知道如何在 Azure 中执行此操作。
其实我是在尝试使用Swagger来实现WCF,错误出现在这段代码中:
Global.asax.cs:
void Application_Start(object sender, EventArgs e)
{
// Swagger
RouteTable.Routes.Add(new ServiceRoute("api-docs", new WebServiceHostFactory(), typeof(SwaggerWcfEndpoint)));
var swaggerHost = new WebServiceHost(typeof(SwaggerWcfEndpoint));
swaggerHost.Open();
}
Web.config:
<services>
<service name="SwaggerWcf.SwaggerWcfEndpoint">
<endpoint address="http://totvsrmwebapp.azurewebsites.net/docs" binding="webHttpBinding" contract="SwaggerWcf.ISwaggerWcfEndpoint" />
</service>
</services>
这里是堆栈跟踪:
'[HttpListenerException (0x5): Access is denied]
System.Net.HttpListener.SetupV2Config() +333
System.Net.HttpListener.Start() +297
System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen() +651
[AddressAccessDeniedException: HTTP could not register URL http://+:80/docs/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details).]
System.ServiceModel.Channels.SharedHttpTransportManager.OnOpen() +1473
System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener) +296
System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback) +122
System.ServiceModel.Channels.TransportChannelListener.OnOpen(TimeSpan timeout) +64
System.ServiceModel.Channels.HttpChannelListener`1.OnOpen(TimeSpan timeout) +67
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +308
System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) +61
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +308
System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +136
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +308
RMWCFWebApp.Global.Application_Start(Object sender, EventArgs e) +236
[HttpException (0x80004005): HTTP could not register URL http://+:80/docs/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details).]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9982013
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): HTTP could not register URL http://+:80/docs/. Your process does not have access rights to this namespace (see http://go.microsoft.com/fwlink/?LinkId=70353 for details).]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9963380
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254'
【问题讨论】:
标签: wcf azure azure-web-app-service