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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:00:24+00:00 2026-05-11T11:00:24+00:00

Please can anybody point out where this code might be going wrong. I am

  • 0

Please can anybody point out where this code might be going wrong. I am trying to create a partial class for the masterpage.

The master pages class:

namespace MuniWeb.Models.SiteMaster{  public class BaseViewData {     public string Title { get; set; }     public string MetaKeywords { get; set; }     public string MetaDescription { get; set; } }  public partial class Site : System.Web.Mvc.ViewMasterPage<MuniWeb.Models.SiteMaster.BaseViewData> {     public Site()     {         ViewData.Model = new BaseViewData();     } }} 

The master page:

<%@ Master Language='C#' Inherits='System.Web.Mvc.ViewMasterPage<MuniWeb.Models.SiteMaster.BaseViewData>' %> 

The error:

Object reference not set to an instance of an object. Line 33:             <div id='footer'> Line 34:                 ApplicationID: Line 35:                 <%= Model.Title %> Line 36:             </div> Line 37:         </div> 

I am just using this as an example. The code I want to use needs to fire for every page to check certain parameters, this is why it is in the master page.

  • 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-11T11:00:25+00:00Added an answer on May 11, 2026 at 11:00 am

    You shouldn’t need to make a partial class. What does your controllers action code look like? The error looks like it could be from not handing the View (and therefore it’s master page) a model.

    Try something like this:

    namespace MuniWeb.Website.ViewDataModels {      public class BaseViewData     {         public string Title { get; set; }         public string MetaKeywords { get; set; }         public string MetaDescription { get; set; }     }      public class SubViewData : BaseViewData     {         public IList<Thing> Things { get; set; }     } } 

    Then define your master page like you had:

    <%@ Master Language='C#' Inherits='System.Web.Mvc.ViewMasterPage<MuniWeb.Website.ViewDataModels.BaseViewData>' %> 

    Now in your controller

    public ActionResult Index() {     SubViewData viewData = new SubViewData();     viewData.Title = 'Page Title';     viewData.MetaKeywords = 'This, that, and the other';     viewData.MetaDescription = 'A really great page about this, that, and the other.';      viewData.Things = _myRepository.GetThings();      return View(viewData); } 

    See how that goes…

    I would ask why the MasterPage NEEDS strongly type ViewData. I understand that yes, sometimes strongly typed viewdata is needed in masterpages but generally you should be able to get way with just using the ViewData name value collection.

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

Sidebar

Ask A Question

Stats

  • Questions 312k
  • Answers 312k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Because in evaluates as false when the last read failed… May 13, 2026 at 10:43 pm
  • Editorial Team
    Editorial Team added an answer Like comments suggests, it is not a framework duty to… May 13, 2026 at 10:43 pm
  • Editorial Team
    Editorial Team added an answer I assume "best partner"= the parner with the highest number… May 13, 2026 at 10:43 pm

Related Questions

There is a lot of discussions of Python vs Ruby, and I all find
I'm Using CakePHPs standard Auth mechanism, but I have some problems with that. Everytime
I want the users to upload files through my webapp I am developing in
I'm trying to work on a kind of code generator to help unit-testing an

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.