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 3937892
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:07:17+00:00 2026-05-20T00:07:17+00:00

Using Castle.Windsor in ASP.NET MVC (3.0) is there any way I can appropriately handle

  • 0

Using Castle.Windsor in ASP.NET MVC (3.0) is there any way I can appropriately handle if one of my dependencies resolves null? For instance, say I have a IMembershipService.

class ServiceInstaller
{
 // ... 
 void Install( // .. )
 { 
  container.Register(
  Component
  .For<IMembershipService>()
  .ImplementedBy<MembershipService>()
  .LifeStyle.PerWebRequest
  );
 }
}

Okay, this works great. Now, perhaps not all of my site requires a user to be logged in. Let’s assume that maybe my web host’s database server crashes for a few hours. In that event, things that looked into the database, or tried to call on my ISession might return null.

What can I do in this case? I can write if(membershipService == null) a hundred times over, but that seems pretty dumb. Is there a built-in solution to say “Hey, if we have an error, do this..?”

  • 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-05-20T00:07:17+00:00Added an answer on May 20, 2026 at 12:07 am

    I think that the service should never be null. If the database is down, the service should be returned nevertheless, but its methods should throw an exception, return null or some default value, depending on the semantic of the service.

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

Sidebar

Related Questions

Is is possible to inject IPrincipal using Castle Windsor into my asp.net mvc controller.
I am using NServiceBus 3.2.7, Castle Windsor 3.1, and ASP.Net MVC 4. I am
My ASP.NET MVC 4 project is using NHibernate (behind repositories) and Castle Windsor, using
I'm developing a web application using ASP.NET MVC and I'm using Windsor Castle as
I have about 4-6 years .NET experience. Primarly using ASP.NET MVC/Nhibernate/Castle Windsor/MSpec/etc in visual
I'm using ASP.NET MVC with Castle Windsor as my IoC container with the component
I'm using Castle Windsor 3.0 for dependency injection in a demo ASP.NET app. One
Using Castle ActiveRecord / NHibernate: Is there a way you can force an ICriterion
I have a Windsor ASP.NET MVC WebAPI project setup like: http://nikosbaxevanis.com/2012/07/16/using-the-web-api-dependency-resolver-with-castle-windsor-scoped-lifetime/ Everything works fine
I'm developing an ASP.NET application using Windsor and NHibernate. I want to use Castle's

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.