简体   繁体   中英

FluentSecurity makes Azure WebRole to fail

I have a ASP.NET MVC website using FluentSecurity. As a Azure Website it works just fine. I need to make it a WebRole. I added a WebRole project but the WebRole fails at startup with a generic "The page cannot be displayed because an internal server error has occurred."

I have a DenyAnonymousAccessPolicyViolationHandler and RequireRolePolicyViolationHandler implementing IPolicyViolationHandler and the whole FluentSecurity setup according to http://blog.mariusschulz.com/setting-up-fluentsecurity-to-use-ninject-for-dependency-resolution .

I discovered that when I delete both classes implementing IPolicyViolationHandler then then WebRole starts just fine. I created a sample project demonstating this issue, you can find it at https://dl.dropboxusercontent.com/u/73642/MvcApplication1.zip .

So how can I get the FluentSecurity work with Azure WebRole including my policy classes?

We had the same problem; working on a Website, but not in a Web Role.

It was because Fluent Security references MVC3, not MVC4. The comments to this bug on Github go into further detail https://github.com/kristofferahl/FluentSecurity/pull/39 .

You can either:

1) Take a local copy of the FluentSecurity.csproj and upgrade it's System.Web.MVC reference to MVC 4, then include it in your solution (this is what we did).

2) Or, as per the Github bug link above "...fix this using assembly redirect in your web.config" like this

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM