Skip to content

ArgumentNullException: HttpContext #7

@cocowalla

Description

@cocowalla

When I first start debugging a project using IIS Express I get an ArgumentNullException in StructureMapDependencyScope.HttpContext, as System.Web.HttpContext.Current is null.

I'm not sure, but this might be because I'm trying to resolve dependencies in Application_Start for use in authorisation filters by calling DependencyResolver.Current.GetService<> - maybe this is too early for the HttpContext to exist?

In any case, it means that StructureMap is not created HTTP-scoped instances; I can end up with multiple instances of my DbContext, for example, despite the fact it should be HTTP-scoped.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions