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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:08:59+00:00 2026-05-11T05:08:59+00:00

Whats the earliest point I can programatically get to the name of the masterpage

  • 0

Whats the earliest point I can programatically get to the name of the masterpage that will be used in an asp.net MVC application?

The idea being changing the viewdata used depending on the master page. I want to be able to set something as early as possible so that individual developers don’t need to know to populate it. Ideally it would just happen in the background.

In the simplist scenario we would have different masterpages for different types of page, such as a default one with a header, leftnav, rightnav and footer or a secure one which could be missing the rightnav.

Thanks

  • 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-11T05:08:59+00:00Added an answer on May 11, 2026 at 5:08 am

    I’d say the point when your master page is known would be right after your view has been resolved by your view engine. You can set your masterpage when calling the View method on your Controller though:

    public ActionResult Index() {   return View('index','masterpagename'); } 

    I think if you want to do anything with your masterpage THAT would be the way. I don’t know the context of your question, but I assume you want to manipulate the view and/or viewdata depending on which masterpage is used? Maybe the solution to your problem is not programmatically getting the name of the masterpage in the first place?

    Addition, after your edit: What you could do is create a new ‘Base’ controller which inherits the default Controller class. Then you override the View methods, and tell your developers to use that:

    public class MySuperController : Controller {   protected override ViewResult View(string viewName, string masterName, object model)   {     // do something here so your masterpage is different depending on the context //     string newMasterName = 'something-something';     return base.View(viewName, newMasterName, model);   } } 

    I ‘think’ all other view methods either get routed through this, or are not used in your case (the ones requiring you to pass an IView).

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

Sidebar

Related Questions

what is the earliest wordpress action where the post that will eventually be shown
Whats the best way to get the current time (HH:MM:SS) using Objective-C. I would
I do this to get the earliest year: select top 1 tblOrders.OrderDate from tblOrders
Posted immediately after the application finishes launching. That's what the Apple docs state. But
What is the earliest version of Visual Studio (C++) that supports the ARM NEON
Can anyone familiar with the Twitter Search API tell me what the earliest possible
I have a problem where I need to get the earliest date value from
Is there a way which I can return more information to the caller that
Whats the best way to check if a username exists in a MySQL table?
Whats wrong with my buttons? here http://hiddenbrookstudio.com/index.swf , see how they rollover and dissappear

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.