Skip to content

Accessing AppController.CurrentUser from child controller constructor raises StructureMap.Building.StructureMapBuildException #2

Description

@Mimisss

Based on your post:
http://benfoster.io/blog/aspnet-identity-stripped-bare-mvc-part-1

The following raises StructureMap.Building.StructureMapBuildException with inner exception Object reference not set to an instance of an object. Debugging reveals this.User in 'AppController' is null:

public class HomeController : AppController
{
        private IMyService service;

        public HomeController(IMyService service)
        {
            this.service.User = this.CurrentUser;
        }
}

Any idea why?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions