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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:11:48+00:00 2026-05-11T02:11:48+00:00

I’ve been playing around with ASP.NET MVC with a site containing a Master Page.

  • 0

I’ve been playing around with ASP.NET MVC with a site containing a Master Page.

I created an MVC user control called ProductThumbnailControl. The user control displays a product and a small thumbnail image. The View is a ViewProduct view which displays full product information – the usercontrol just being a UI element off to the site.

 public partial class ProductThumbnailControl :                       System.Web.Mvc.ViewProductControl<ViewProductsModel>  {   } 

I read a blog entry that shows how user controls consume ViewData. I learned that the user control can automagically get its model from the parent View. Since it’s consuming the same data the View doesn’t need to explicitly pass anything to the user control, making for cleaner markup and code.

So now I’ve learned that the Master Page is using the same ViewData as the page. This means means the Master Page itself doesn’t really have a model to help render itself.

Question

Whats the correct way for a Master Page to get its data in the first place?

I thought about trying the following?

You could have a SiteModel :

//Arbitrary properties for example class SiteModel  {     public string PartnerId {get; set;}     public ShoppingCart ShoppingCartContents {get; set;}         public string CurrentUserId {get; set;} } 

The View inherits from it:

class ViewProductModel : SiteModel  {     public Product Product {get; set;} } 

SiteModel would be consumed by the Master Page. Views could use data from it if needed – if they needed to display the current user’s email somewhere.

Is this a horrible idea?

Should the master page just get its data from wherever it needs it?

What if I want to include a user control in the masthead?

Where would it get its ViewData from since there is only one ViewData object for the whle page?

Would I have to use this horrible syntax that I hate and pass the master page’s user control an explicit model?

Html.RenderUserControl("~/Views/Account/UserControls/Header.ascx",   null, new { SelectedItem = "Profile" }) 

What’s the best way to tackle this scenario?

  • 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. 2026-05-11T02:11:48+00:00Added an answer on May 11, 2026 at 2:11 am

    Our master page takes data from the view. We use strongly typed view names for our views and in the methods for that implementation we also add standard view data that every page needs from our persistent objects (like the application menu structure info, the user info to display on screen and so forth).

    This does have the disadvantage of making our view data for the master page not strongly typed like it is for the Model object, but it works very well for us.

    Your idea is also good. As the idea of the Master page is similar to the idea of inheritance, why not use inheritance to setup your model objects. You could take it a step further and create a model factory that produces your model objects and sets the base class data while it does so.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I'm making a simple page using Google Maps API 3. My first. One marker
I have just tried to save a simple *.rtf file with some websites and

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.