Web.config Azure Web角色上的访问被拒绝

时间:2016-01-04 19:39:51

标签: c# asp.net azure iis azure-web-roles

我的Azure网络角色突然停止处理以下错误 “拒绝访问路径'F:\ sitesroot \ 0 \ Web.config'。”
没有最近发布的更改或配置,它一直没有任何问题,直到昨天!我检查了 Web.config 的权限,我看到所有用户都有Read / Execute。这是堆栈跟踪:

    [UnauthorizedAccessException: Access to the path 'F:\sitesroot\0\Web.config' is denied.]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +216
   System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) +1430
   System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) +205
   System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) +87
   System.IdentityModel.Tokens.UpdateValidatingIssuerNameRegistry.FlushDocument(String originalXml, String location) +218
   System.IdentityModel.Tokens.UpdateValidatingIssuerNameRegistry.UpdateIssuerNameRegistryElement(String pathToConfig, String fedMetadataAddress, String serviceName) +493
   Manager.MvcApplication.RefreshValidationSettings() in c:\GitHub\mfs_backoffice\2013_2.2\KCI.MFS.Manager\ManagerMFS\Global.asax.cs:37
   Manager.MvcApplication.Application_Start() in c:\GitHub\mfs_backoffice\2013_2.2\KCI.MFS.Manager\ManagerMFS\Global.asax.cs:30

[HttpException (0x80004005): Access to the path 'F:\sitesroot\0\Web.config' is denied.]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +12601629
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +175
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475

[HttpException (0x80004005): Access to the path 'F:\sitesroot\0\Web.config' is denied.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12618676
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12458293  

Updade:
在遇到问题后我也重新启动,重新映像并重新部署了实例,但都没有工作。我还尝试将我的文件复制到实例上的不同位置(在D盘中)并将其作为另一个站点添加到IIS中,但是当我尝试浏览它时它仍然给我同样的错误

1 个答案:

答案 0 :(得分:0)

解决我们的问题:

问题是我们正在修改 ApplicationStart()方法中的 Web.config ,以便根据Microsoft建议的滚动新公钥的方法滚动我们的密钥:{{3} }

    protected void RefreshValidationSettings()
    {
        string configPath = AppDomain.CurrentDomain.BaseDirectory + "\\" + "Web.config";
        string metadataAddress = ConfigurationManager.AppSettings["ida:FederationMetadataLocation"];
        ValidatingIssuerNameRegistry.WriteToConfig(metadataAddress, configPath);
    }

所以我停止使用Microsoft方法来滚动公钥,并修复了问题(现在我们需要每六个月手动更新一次公钥)。但是,我无法找到为什么Azure Web角色上的权限策略已更改