我有一个使用FluentSecurity的ASP.NET MVC网站。作为一个Azure网站,它工作得很好。我需要让它成为一个WebRole。我添加了一个WebRole项目,但WebRole在启动时失败,并显示一条通用的“页面无法显示,因为发生了内部服务器错误”。
我有一个实现IPolicyViolationHandler的DenyAnonymousAccessPolicyViolationHandler和RequireRolePolicyViolationHandler,以及根据http://blog.mariusschulz.com/setting-up-fluentsecurity-to-use-ninject-for-dependency-resolution的整个FluentSecurity设置。
我发现,当我删除两个实现IPolicyViolationHandler的类时,WebRole就会正常启动。我创建了一个演示此问题的示例项目,您可以在https://dl.dropboxusercontent.com/u/73642/MvcApplication1.zip上找到它。
那么,我如何让FluentSecurity与Azure WebRole一起工作,包括我的策略类?
发布于 2013-10-03 00:13:53
我们也有同样的问题;在网站上工作,但不是在Web角色中工作。
这是因为Fluent Security引用的是MVC3,而不是MVC4。在Github上对这个bug的评论更详细地介绍了https://github.com/kristofferahl/FluentSecurity/pull/39。
您可以执行以下任一操作:
1)获取FluentSecurity.csproj的本地副本并将其System.Web.MVC引用升级到MVC4,然后将其包含在您的解决方案中(这就是我们所做的)。
2)或者,根据上面的Github bug链接"...fix this using assembly redirect in your 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>https://stackoverflow.com/questions/17684377
复制相似问题