question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem to register type in IoC with LifestylePerWebRequest scope

See original GitHub issue

Abp 10.3.0

Hi,

When I try register a object in my module in MVC web with LifestylePerWebRequest, a exception is throw:


Looks like you forgot to register the http module Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule
To fix this add
<add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" />
to the <httpModules> section on your web.config.
Windsor also detected you're running IIS in Integrated Pipeline mode. This means that you also need to add the module to the <modules> section under <system.webServer>.
Alternatively make sure you have Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 assembly in your GAC (it is installed by ASP.NET MVC3 or WebMatrix) and Windsor will be able to register the module automatically without having to add anything to the config file.

I put correct configuration in modules section in web.config, but don’t works anyway:

<system.webServer>
    <!--configuration/system.webServer/security/requestFiltering/requestLimits@maxQueryString-->
    <security>
      <requestFiltering>
        <requestLimits maxQueryString="5000" maxUrl="1000" />
      </requestFiltering>
    </security>
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="WebDAVModule" />
      <add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.Windsor" />
    </modules>

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
hikalkancommented, Aug 31, 2016

OK, it was a bit long time ago lastly I worked with web request lifestyle. I normally don’t use it. I’ll try it again and inform you.

0reactions
thiagoburgocommented, Sep 2, 2016

Ok, I will try…

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to register services in scoped lifestyle behaving like ...
This code executes on every web request var container = IoCResolverFactory.GetContainer(); scope = container.BeginScope(); // the request ...
Read more >
Wiring HttpControllerContext With Castle Windsor - ploeh blog
The overall solution should still adhere to the Register Resolve Release pattern, so registering a captured HttpControllerContext is a no-go.
Read more >
WindsorContainer not releasing transient components ...
I'm using Windsor as IoC through the public sealed class WindsorContainerAdapter : IContainerAdapter, IDisposable, IRelease.
Read more >
How do I work with per-request lifetime scope?
As you analyze the registrations in the problem dependency chain, look at the lifetime scopes for which they're registered. If you have a...
Read more >
C# – Castle.Windsor lifestyle depending on context
I have a web application where many components are registered using .LifestylePerWebRequest() , now I've decided to implement Quartz.NET, a .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found