当我尝试将具有RavenDB嵌入式实例的MVC4站点部署到新的Azure网站预览功能时,收到“拒绝访问”消息。该站点在本地运行良好。

这是我配置Raven的方法:

//Initialize the RavenDB Data Store
        Raven.Database.Server.NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(8887);

        var documentStore = new EmbeddableDocumentStore()
        {
            DataDirectory = "~\\App_Data",
            UseEmbeddedHttpServer = true,
            Configuration = { Port = 8887 }
        };

        documentStore.Initialize();

这是我浏览该站点时的堆栈跟踪:
Access is denied

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.NetworkInformation.NetworkInformationException: Access is denied

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[NetworkInformationException (0x5): Access is denied]
   System.Net.NetworkInformation.SystemIPGlobalProperties.GetAllTcpConnections() +1570717
   System.Net.NetworkInformation.SystemIPGlobalProperties.GetActiveTcpListeners() +74
   Raven.Database.Util.PortUtil.FindPort() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Database\Util\PortUtil.cs:110
   Raven.Database.Util.PortUtil.GetPort(String portStr) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Database\Util\PortUtil.cs:44
   Raven.Database.Config.InMemoryRavenConfiguration.Initialize() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Database\Config\InMemoryRavenConfiguration.cs:170
   Raven.Database.Config.RavenConfiguration.LoadConfigurationAndInitialize(IEnumerable`1 values) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Database\Config\RavenConfiguration.cs:28
   Raven.Database.Config.RavenConfiguration..ctor() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Database\Config\RavenConfiguration.cs:17
   Raven.Client.Embedded.EmbeddableDocumentStore.get_Configuration() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Embedded\EmbeddableDocumentStore.cs:63
   Raven.Client.Embedded.EmbeddableDocumentStore.set_DataDirectory(String value) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Embedded\EmbeddableDocumentStore.cs:90
   Solarity.DesignSearch.Website.Bootstrapper.BuildUnityContainer() in c:\a\src\Solarity.DesignSearch\Solarity.DesignSearch.Website\Bootstrapper.cs:35
   Solarity.DesignSearch.Website.Bootstrapper.Initialise() in c:\a\src\Solarity.DesignSearch\Solarity.DesignSearch.Website\Bootstrapper.cs:20
   Solarity.DesignSearch.Website.MvcApplication.Application_Start() in c:\a\src\Solarity.DesignSearch\Solarity.DesignSearch.Website\Global.asax.cs:23

[HttpException (0x80004005): Access is denied]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9859725
   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): Access is denied]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9873912
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

最佳答案

我设法使其正常运行,尽管它并不理想。您可能会在我的原始帖子中注意到,我将UseEmbeddedHttpServer设置为true。这样一来,我可以浏览到http:[MyUrl]:8081并获取RavendDB Management Studio,以便可以浏览我的数据。出于某种原因,设置此属性时,RavenDB希望执行与将端口设置设置为自动(Port = *)时相同的端口检查。

我相信RavenDB可能需要修复,以便在UseEmbeddedHttpServer为True时采用Port设置,并允许您在创建时设置EmbeddedDocumentStore的Configuration属性。

但是与此同时,您只需指定端口即可真正使MVC4站点与Azure网站上的EmbeddedDocumentStore一起使用。另外,您确实确实必须使用AppSettings配置,而不是在创建时设置EmbeddedDocumentStore的Configuration属性(就像我在上面尝试过的那样)。这篇文章(stackoverflow.com/questions/11529159/)显示了如何做。

不幸的是,我仍然没有找到一种运行EmbeddedHttpServer的方法,因此我可以使用Raven Management Studio。如果我想办法,我将在此处发布解决方案。

关于RavenDB嵌入在Azure网站上-拒绝访问,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13033305/

10-13 08:55