gpt4 book ai didi

wcf - 使用Azure时如何解决此错误 "AddressAccessDeniedException"?

转载 作者:行者123 更新时间:2023-12-04 15:53:36 25 4
gpt4 key购买 nike

我有一个托管在 ASP.NET Web 应用程序中的 WCF 服务,在 Azure 中作为应用服务运行。

当我在本地计算机上运行此项目时没有错误。但是当部署到Azure时,出现以下错误:

[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).]

有很多关于本地计算机的此错误的帖子,但与 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'

最佳答案

我已经重现了您的问题。根据我的经验,Azure Web应用程序不允许我们注册url“http://totvsrmwebapp.azurewebsites.net/docs”。如果你想这样做,我建议你使用Azure云服务,并在启动任务中执行命令(netsh http add urlacl url=)。更多云服务信息请引用this article 。看看this article了解如何使用启动任务。

关于wcf - 使用Azure时如何解决此错误 "AddressAccessDeniedException"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40533586/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com