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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:07:43+00:00 2026-05-12T10:07:43+00:00

In almost every page in my ASP.NET MVC site I am using information about

  • 0

In almost every page in my ASP.NET MVC site I am using information about the user. This is usually pulling in information about the company they work for in the Model to pass through to the view, or in the View to establish which parts of the page the user can view with their permissions.

Instead of getting the User in every Model, is there a way to easily have the User data available all the time? I.e. should I set up a base model, or have some ‘master’ controller that passes the user through in ViewData?

Any thoughts, or even better any code would be greatly 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-12T10:07:43+00:00Added an answer on May 12, 2026 at 10:07 am

    It is a great idea. I use a MasterModel consistently in all my MVC projects.

    For this to work you need to subclass all your view models and also strongly type your MasterPage to MasterModel.

    public class MasterModel
    {
        string UserName { get; set; }
    }
    
    public class HomeModel : MasterModel
    {
    }
    
    public class NewsModel : MasterModel
    {
    }
    
    <%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage<MasterModel>" %>
    
    User name: <%= Model.UserName %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've had this intermittent issue when using asp.net. My site is dynamically compiled. Sometimes
A login page on our asp.net website uses https – while almost all of
I've been spending the past several weeks working on my asp.net mvc site following
I'm trying to get setup using the DataAnnotations validator in ASP.Net MVC 2.0 Beta,
I'm developing a web site in which you can login from almost every page.
I'm starting a Drupal 7 site and have noticed that almost every page will
Ever since I've started asp.net mvc development my experience is almost 80% jQuery, only
Almost every major news media outlet is reporting that Apple will stop using Google
Almost every ios app now has something like Feed option. Programming that usually includes
This happens almost every time I init a new repo. Start a new project.

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.