It is possible在 Azure Web Apps上运行一个 suave.io应用程序,因为一个名为 HttpPlatformHandler的IIS8功能.我尝试以相同的方式运行一个自我托管的OWIN应用程序,但启动时出现异常:
Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.httpListenerException: Access is denIEd at System.Net.httpListener.SetupV2Config() at System.Net.httpListener.Start() at Microsoft.Owin.Host.httpListener.OwinhttpListener.Start(httpListener Listener,Func`2 appFunc,IList`1 addresses,IDictionary`2 capabilitIEs,Func`2 loggerFactory) at Microsoft.Owin.Host.httpListener.OwinServerFactory.Create(Func`2 app,IDictionary`2 propertIEs) --- End of inner exception stack trace --- at System.RuntimeMethodHandle.InvokeMethod(Object target,Object[] arguments,Signature sig,Boolean constructor) at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,Object[] parameters,Object[] arguments) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,BindingFlags invokeAttr,Binder binder,CultureInfo culture) at Microsoft.Owin.Hosting.ServerFactory.ServerFactoryAdapter.Create(IAppBuilder builder) at Microsoft.Owin.Hosting.Engine.HostingEngine.StartServer(StartContext context) at Microsoft.Owin.Hosting.Engine.HostingEngine.Start(StartContext context) at Microsoft.Owin.Hosting.Starter.DirectHostingStarter.Start(Startoptions options) at Microsoft.Owin.Hosting.Starter.HostingStarter.Start(Startoptions options) at Microsoft.Owin.Hosting.WebApp.StartImplementation(IServiceProvIDer services,Startoptions options) at Microsoft.Owin.Hosting.WebApp.Start(Startoptions options) at Microsoft.Owin.Hosting.WebApp.Start[TStartup](Startoptions options) at Microsoft.Owin.Hosting.WebApp.Start[TStartup](String url) at WebAppSample.Program.Main(String[] args) in c:\Users\egger\Workspace\WebAppSample\WebAppSample\Program.cs:line 14
看来我不允许开一个港口.我的web.config看起来像这样:
<?xml version="1.0" enCoding="UTF-8"?><configuration> <system.webServer> <handlers> <remove name="httpplatformhandler" /> <add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="UnspecifIEd" /> </handlers> <httpPlatform stdoutLogEnabled="true" stdoutLogfile="site.log" startupTimelimit="20" processpath="%HOME%\site\wwwroot\WebAppSample.exe" arguments="%http_PLATFORM_PORT%"> </httpPlatform> </system.webServer></configuration>
我使用http_PLATFORM_PORT来侦听正确的端口.我的网络应用程序启动服务器如下:
class Program{ static voID Main(string[] args) { var port = int.Parse(args[0]); var url = string.Format("http://127.0.0.1:{0}",port); Console.Writeline("Starting web app at {0}",url); using (WebApp.Start<Startup>(url)) { Console.Readline(); } }}public class Startup{ public voID Configuration(IAppBuilder app) { app.UseErrorPage(); app.UseWelcomePage("/"); }}
该URL似乎是好的,因为我得到如下输出:启动Web应用程序http://127.0.0.1:32880.
web.config和所有二进制文件都在根目录下,我使用本地的git repo发布了该应用程序.
为什么不能使用OWIN打开端口?与suave.io样本有什么不同?
编辑:
我刚刚看到有一个要求来支持这个确切的情况:https://feedback.azure.com/forums/169385-web-apps-formerly-websites/suggestions/4606121-support-owin-self-hosting-in-azure-websites
(您也可能需要重新启动Azure仿真器)
总结以上是内存溢出为你收集整理的在Azure Web Apps中运行自我托管的OWIN应用程序全部内容,希望文章能够帮你解决在Azure Web Apps中运行自我托管的OWIN应用程序所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)