Azure的Web角色过程中不加载的web

Azure的Web角色过程中不加载的web

本文介绍了Azure的Web角色过程中不加载的web.config?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行在Windows Azure模拟器的web项目和web.config文件没有被加载。我正在作为一个完整的IIS应用程序,我可以去应用程序运行在IIS dev的面料已推出后,并浏览到文件的位置,并验证了正确的web.config文件确实是文件夹中。

I am running a web project in the Windows Azure Emulator and the web.config is not being loaded. I am running as a full IIS application, and I can go to the application running in IIS after the dev fabric has launched, and browse to the file location, and have verified that the correct web.config is indeed in the folder.

当我跑我的应用程序,没有一个标准appSetting键,配置,或企业图书馆配置的加载。提供给我的所有数据被从在machine.config拉。

When I run my application, none of the standard appSetting keys, configuration, or Enterprise library config is loaded. All data available to me is being pulled from the machine.config.

我已经看配置管理器数据时,康涅狄格州串集合验证了这一点,并有许多关于不能够得到我的分贝误差修改为默认值是不存在的,只有康涅狄格州字符串是本地SQL前从machine.config中preSS服务器信息。

I have verified this by looking at the configuration manager data, the conn strings collection, and have lots of erros about not being able to get to my db as the default is not there and the only conn string is the local sql express server info from machine.config.

推荐答案

您无法正常访问的时候,因为它是在另一个进程中运行的作用盯着web.config中。在你的角色属性的角色设置(右键点击你的角色,并选择属性,然后选择设置选项卡)是你应该有你的角色设置,你可以从你的角色code这样的访问这些:

You can't normally access the web.config when the role is staring since it is running in another process. The Role Settings on your Role Properties (right-click your Role and select Properties, then select the Settings tab) is where you should have your role settings, you can access these from your role code like this:

RoleEnvironment.GetConfigurationSettingValue("MySetting")

如果您还是真的想使用你的web.config你的可能的可以先用鼠标右键单击we​​b.config文件,并选择复制如果有更新,这将复制<$ C $这样做C>的web.config 到 System.Environment.CurrentDirectory 这是所有其他角色奠定组装。然后,你可以通过使用XML读取器加载它和你自己解析它,我不认为 WebConfigurationManager 将帮助你,因为它需要一个虚拟路径,所以我怀疑你会自己解析它。

If you still really want to use your web.config you might be able to do so by first right-clicking the web.config and selecting Copy if Newer, this will copy web.config to the System.Environment.CurrentDirectory which is where all the other role assembles lay. Then you can load it by using a XML reader and parse it yourself, I don't think WebConfigurationManager will help you as it expects a virtual path, so I suspect you would have to parse it yourself.

这篇关于Azure的Web角色过程中不加载的web.config?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 15:05