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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:12:20+00:00 2026-05-20T21:12:20+00:00

We have an MVC 2/Entity Framework app that is a replacement/rewrite of an existing

  • 0

We have an MVC 2/Entity Framework app that is a replacement/rewrite of an existing system. It’s been using ASP membership for security during development but now we need to replace this so it is compatible with the customers existing security infrastructure, partly to allow both old and new systems to run side by side for a while and also because they already have a process and system to setup customers and we can’t replace this yet.

The existing security centers around a table in the database that stores a certificate number mapped to a customerid. The customerid is then used to filter relevant data sent back in the UI.

My question is what is the most efficient way to go from certificate number to customerid. Each MVC controller action can grab the certificate number from the HTTPContext and do a look up in the security table to get the customerid but it seems inefficient to this on every controller action. The system could have 1000 concurrent users. We are thinking that it should work similiar to ASP.NET membership, where a username/password login generates a security token that is then placed in a cookie. Instead we would have the certificate replace the username/password login but it would still generate a security token.

The problem is we don’t know enough about this system to determine how to go about it, or even if it’s the best way forward. If anyone can offer any advice or pointers to how we would implement this it would be much appreciated.

  • 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-20T21:12:21+00:00Added an answer on May 20, 2026 at 9:12 pm

    Either

    1. add it to the users Session once you look it up so its available upon login.

    2. add it to the forms auth ticket (make sure you are patched for the POET vulnerability
      or this could be forged)

    or

    1. cache the table in memory and do you lookups as required. this might be ‘slightly’ less efficient than session if you are already using the session because you will then be locking two collections (normal session usage) and the collection you store this in will have to be synchronized.

    If you choose to store this information in the ticket you can create a CustomIdentity object to store this customer id in.

     /// <summary>
            /// Deserializes the forms auth cookie with our userid, companyid, etc.
            /// </summary>
            /// <param name="sender">
    </param>
            /// <param name="e"></param>
            void Application_PostAuthenticateRequest(object sender, EventArgs e)
            {
                HttpCookie authCookie = HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
                if (authCookie != null)
                {
                    string encTicket = authCookie.Value;
                    if (!String.IsNullOrEmpty(encTicket))
                    {
                        FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(encTicket);
                        CustomIdentity id = new CustomIdentity(ticket);
                        //Assign the roles. If they aren't available, get from the session.
                        //The problem is when we use this custom principal it seems our roles arent populated.
    
                        GenericPrincipal principal = new GenericPrincipal(id, new string[] { "User" });
    
                        HttpContext.Current.User = principal;
                    }
                }
            }
    

    After each request is authenticated via the forms auth ticket you can deserialize this information into a Customer IIdentity object which can then be read throughout the application via:

     int companyId = ((CustomIdentity)HttpContext.Current.User.Identity).CompanyId
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET MVC 3 (using Entity Framework 4.2) application that uses transactions
General Info: ASP.NET MVC app using ADO.NET Entity Framework SQL Server 2005 I have
Using ASP MVC and Entity Framework. In the view, you have a page declaration
I am using the asp.net mvc with the Entity Framework. I have a list
I have an application developed in ASP.NET MVC using Entity Framework / Sql Server
I have an ASP.NET MVC 3 app that is using SQL Server CE 4.0
I have an MVC 3 project that I am working on using Entity Framework
I am building a website using ASP.NET MVC and entity framework. I have a
I have an MVC app using Entity Framework and a SQL Server 2008 database.
I have a ASP.NET MVC 4 project - CodeFirst with Entity Framework - that

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.