Fluent Security使Azure Web角色失败

时间:2013-07-16 18:33:50

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

我有一个使用FluentSecurity的ASP.NET MVC网站。作为Azure网站,它的工作正常。我需要把它变成一个WebRole。我添加了一个WebRole项目,但WebRole在启动时失败,并且通用“由于发生了内部服务器错误,因此无法显示该页面。”

根据http://blog.mariusschulz.com/setting-up-fluentsecurity-to-use-ninject-for-dependency-resolution,我有DenyAnonymousAccessPolicyViolationHandlerRequireRolePolicyViolationHandler实施IPolicyViolationHandler以及整个FluentSecurity设置。

我发现当我删除两个实现IPolicyViolationHandler的类时,那么WebRole就可以了。我创建了一个示例项目来演示此问题,您可以在https://dl.dropboxusercontent.com/u/73642/MvcApplication1.zip找到它。

那么如何让FluentSecurity与Azure WebRole一起使用,包括我的策略类?

1 个答案:

答案 0 :(得分:0)

我们遇到了同样的问题;在网站上工作,但不在网络角色中工作。

这是因为Fluent Security引用了MVC3,而不是MVC4。对Github上的这个bug的评论进一步详细说明https://github.com/kristofferahl/FluentSecurity/pull/39

你可以:

1)获取FluentSecurity.csproj的本地副本,并将其System.Web.MVC引用升级到MVC 4,然后将其包含在您的解决方案中(这就是我们所做的)。

2)或者,根据上面的Github错误链接“...使用你的web.config中的程序集重定向修复此问题”

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
  </dependentAssembly>
</runtime>