Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7907645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:33:17+00:00 2026-06-03T11:33:17+00:00

I have an ASP.NET MVC application which sets up an Autofac IOCContainer within the

  • 0

I have an ASP.NET MVC application which sets up an Autofac IOCContainer within the BeginRequest routine in Global.asax.

All is fine until one of my IIS7 UrlRwrite rules/conditions is met, e.g. lowercase url. I notice that as soon as I put an upper case letter within the url, so as the url rewrite rule is fired, the BeginRequest routine isn’t reached, but the EndRequest routine is.

The problem I have with this is that the IOCContainer is never set in this scenario, so when EndRequest is fired and I attempt to dispose of the web context/ioc container, it errors as there it was never set in the first place.

Why does the BeginRequest never get reached in the above scenario, and is there a common workaround for the IOC issue that arises because of it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T11:33:19+00:00Added an answer on June 3, 2026 at 11:33 am

    The AutofacDependencyResolver that is part of the Autofac MVC integration already creates a new lifetime scope at the start of each HTTP request and will dispose it when the HTTP request ends. You should not need to manage this yourself. Do you have this problem when you use the DependencyResolver mechanism?

    var builder = new ContainerBuilder();
    builder.RegisterControllers(typeof(MvcApplication).Assembly);
    var container = builder.Build();
    DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
    

    You can find out more about the MVC integration on the Autofac wiki.

    http://code.google.com/p/autofac/wiki/Mvc3Integration

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form within my Asp.Net MVC application which returns a Null reference
I have a ASP.NET MVC application which is build up as an assembly that
I have an ASP.NET MVC 3 application which has a post action called Create
I have an .NET 4.0 ASP.NET MVC application, which also hosts a Workflow Foundation
I created a simple ASP.NET MVC version 1.0 application. I have a ProductController which
We have an ASP.NET application on ASP.NET 4.0 using MVC 3 which uses Windows
I have an ASP.NET MVC application for which I store uploaded content files in
I have an ASP.NET MVC 2 application which in part allows a user to
I have an ASP.NET MVC 2 application in which I am creating a custom
I have a jQuery accordion in a page in ASP:Net MVC application in which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.