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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:55:58+00:00 2026-06-01T20:55:58+00:00

Im using a base controller & OnActionExecuting to get ‘common’ site data that I

  • 0

Im using a base controller & OnActionExecuting to get ‘common’ site data that I want to show & keep accross most page’s (name, ID etc… not more than 4/5 fields)

The Method in OnActionExecuting reads the database & saves to ViewBag which Ipick up in my Views but I cant help thinking this is a waste as it needs a DB call for every OnActionExecuting.

How can consolodate these DB calls and slim down the DB access?

  • 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-06-01T20:55:59+00:00Added an answer on June 1, 2026 at 8:55 pm

    What I have done on a recent project is during Login I get the ‘common’ data which in this case was UserID, FirstName and an ImageName, I saved it in the Auth Ticket like this :

    UserData = pModel.PartyId.ToString() + "|" + pModel.BusinessName + "|" + pModel.FirstName + "|" + pModel.LastName + "|" + pModel.ImageUrl + "|" + UsersRole + "|" + IsAct;//PID, BusName, FirstName, LastName, imgUrl, Role, IsAct
    
    // Create the cookie that contains the forms authentication ticket
    HttpCookie authCookie = FormsAuthentication.GetAuthCookie(UN, true);
    FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);
    FormsAuthenticationTicket newTicket = new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, UserData);
    authCookie.Value = FormsAuthentication.Encrypt(newTicket);
    System.Web.HttpContext.Current.Response.Cookies.Add(authCookie);
    

    I then retreive this Cookie when the data is needed and get the data out of it like this :

    var cookie = context.Request.Cookies[FormsAuthentication.FormsCookieName];
    dynamic UN = FormsAuthentication.Decrypt(cookie.Value);
    string UserData = UN.UserData;//PID, BusName, FirstName, LastName, imgUrl, Role, IsAct
    string[] pFields = UserData.Split('|');
    string[] MyRoles = { pFields[5] };
    

    Please Note : This is only good for static data that you know wont change during the login session & be careful what you post in this Cookie.

    Don’t bloat the cookie either keep the fields to a minimum, max is 4K but I aim for 500-1000 bytes.

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

Sidebar

Related Questions

I understand that the libraries and base classes & controllers get loaded when the
I am using form base authentication in my Sharepoint site. On my login page
We are using a base class where we set the background picture. That code
For my tests I'm using a base class MyTestBase defining a method setup() that
i need to update some entry in my data base using jdo in java
I want to have one model & view that is served by multiple controllers
In Short: Does any know a way from the base controller to get a
I started using Base.js for a class inheritance. In Base.js a class should be
I have a small code base using Subsonic 2.1 in my project. I would
when accessing foo() of base using derived class's object. #include <iostream> class base {

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.