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

  • Home
  • SEARCH
  • 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 4542320
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:22:24+00:00 2026-05-21T15:22:24+00:00

Here is what I am trying to do: I have implemented Form Authentication in

  • 0

Here is what I am trying to do:
I have implemented Form Authentication in ASP.NET MVC. I have IUser Interface which conforms to IPrincipal (System.Security.Principal). The custom IUser have additional properties and can be considered as a DTO. I need to use this user in different layers.

Currently my base controller checks whether the form is Authenticated and reconstructs the IUser as in Code1. I am passing this current User to Service Layer, which passes them to domain layer and then it gets to Events and Event Handlers( domain events).

All layers are Interface based and StructureMap is used as IoC.
My IoC is a separate class Library.

I am looking for a way to avaoiding pass user information to each and every method. I found that I could inject Custom Instance of a class as described in link http://structuremap.net/structuremap/InstanceExpression.htm#section11

I plan to create a Method

public void SetCurrentUser(IUser user)
{
    // Something Similart to below ( Below code may be wrong)

    //For<IUser>().TheDefault.IsThis(user);

}

and

have IUser in all class constructors which needs to know about current user

Questions

1) is this a right way to pass User Information to all layers and do you think it will work.

2) Is this safe, Can a user in one session be hijacked from another session?

Thank you,

Mar

Code(1)

string[] roles = userData.Split(',');
// Create a new Generic Principal Instance and assign to Current User
IUser _currentUser= new User
{
    IsApplicationUser = Convert.ToBoolean(roles[0].ToString()),
    Role = (UserRole)Enum.Parse(typeof(UserRole), roles[1].ToString()),
    Id = new Guid(ticket.Name),
    Email = roles[3].ToString(),
    Name = roles[2].ToString(),
    CompanyName = roles[4].ToString(),
    DealerId = roles[5].ToString(),
    LocationId  = roles[6].ToString()
};
  • 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-21T15:22:25+00:00Added an answer on May 21, 2026 at 3:22 pm
    For<IUser>().HybridHttpOrThreadLocalScoped().Use( container => {
        buildUserInstanceFromThreadCurrentPrincipal();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement a sorted list. I have created the class I
Hi I have been trying to implement auto complete in my site from 2
I have the following classes defined: public interface Thingy { ... } public class
I have a strongly typed viewpage that I created that looks like this: <%@
I am trying to port some C++ code from Windows to Solaris(Unix). There are
Is it possible in C++ to have two classes, let's call them A and
I am working on a traveling salesman problem here and my p-queue isn't operating
I am trying to implement a lookup feature in Excel Vba. I do not
I am currently trying to implement a job queue in php. The queue will
I am trying to use StructureMap to register some types that implement a generic

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.