gpt4 book ai didi

asp.net-mvc - 在 asp.net MVC 上创建 Azure 存储表

转载 作者:行者123 更新时间:2023-12-01 20:03:32 25 4
gpt4 key购买 nike

我正在按照这篇博客文章创建一个 azure 存储表: http://blogs.msdn.com/jnak/archive/2008/10/28/walkthrough-simple-table-storage.aspx

它在 asp.net webform web_role 上运行良好。

我使用 asp.net mvc 作为 Web 角色重新创建了相同的项目,但它在应用程序启动时总是失败。这一行:

StorageAccountInfo account = StorageAccountInfo.GetDefaultTableStorageAccountFromConfiguration();

似乎总是无法获取帐户共享 key 。

如果我将该行从全局 asax 应用程序启动移动到 default.aspx,它工作得很好。

  • 与 webform 相比,在 azure asp.net mvc 中初始化存储表有什么区别吗?
  • 为什么我无法在应用程序启动时获取 azure appsettings?

  • 这是事件查看器中的错误调用堆栈

    Exception information:     Exception type: HttpException     Exception message: No account key specified! Request information:     Request URL: http://127.0.0.1:5100/do.__rd_runtime_init__?shutdownEvent=1B671B93FD-4153-4834-9D5D-595EFC6C19EE1D     Request path: /do.__rd_runtime_init__     User host address: 127.0.0.1     User:      Is authenticated: False     Authentication Type:      Thread account name: *****Thread information:     Thread ID: 6     Thread account name: *****    Is impersonating: False     Stack trace:    at System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app)   at System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers)   at System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context)   at System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context)   at System.Web.HttpApplicationFactory.GetPipelineApplicationInstance(IntPtr appContext, HttpContext context)   at System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)

    最佳答案

    查看http://msdn.microsoft.com/en-us/library/microsoft.servicehosting.serviceruntime.rolemanager.aspx的“备注” :

    The Windows Azure fabric runs IIS 7.0 in integrated mode. In integrated mode, the Application_Start event does not support access to the request context or to the members of the RoleManager class provided by the Windows Azure SDK runtime API. If you are writing an ASP.NET application that accesses the request context or calls methods of the RoleManager class from the Application_Start event, you should modify it to initialize in the Application_BeginRequest event instead.

    For an example that shows how to use the Application_BeginRequest event, see the PersonalWebSite Sample that ships with the Windows Azure SDK.

    关于asp.net-mvc - 在 asp.net MVC 上创建 Azure 存储表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/990389/

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