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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:11:16+00:00 2026-06-14T08:11:16+00:00

I have a ASP.Net 4.0 web application whose pages have a common layout (top

  • 0

I have a ASP.Net 4.0 web application whose pages have a common layout (top navigation bar, left navigation bar, logo etc…).
Masterpages would be perfect for the layout part, and this is what I am planning to use. I am not used to working with Masterpage, so many of my plans are still to be tested.
However, I also want my pages to have some common functionality which should be performed before I render the HTML of the page. This functionality includes checking whether the user has access to that page. Moreover that common functionality differs slightly from page to page. Some pages will not even need it.
You would think it was obvious to include this functionality in the Masterpage, and have the functionality depend on which content page is requested.
However it has to be put before the content pages page_load fires, since its result has influence on rendering the page.
Is there a best practice as where to put this functionality, knowing that we need information from the content page to parametrize the functionality.
Ideally that would be in the OnInit() of the Masterpage, since this is run before all. But I do not believe I can retrieve the necessary information from the content page at this time.

Thanks a lot
Jihad

  • 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-14T08:11:17+00:00Added an answer on June 14, 2026 at 8:11 am

    The MasterPage is not the appropriate place for this functionality. The best place for this would be in a custom base Page class where your special functionality is in your derived Page. That way you can inherit your custom class and call the functionality that you need on a page by page basis.

    public class MyCustomPage : System.Web.UI.Page
    {
        public bool IsAuthorized(string someCriteria)
        {
            // run special check
        }
    }
    

    Then when you create an individual page in the site, you simply switch its inheritance from System.Web.UI.Page to your own class.

    public class MyNewWebPage : MyNameSpace.MyCustomPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsAuthorized("myCriteria"))
                Response.Redirect("SomewhereElse.aspx");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ASP.NET web application which has more than 100 pages. Each page
I am developing a web application in ASP.NET. The menu/ navigation bar is at
I have a asp.net web application that uses C#. It logs in on a
I have an ASP.NET web application the entire site is browsed over HTTPS using
I have an asp.net web application written in C# using a SQL Server 2008
We have an ASP.NET web application hosted by a web farm of many instances
I have an ASP.NET web application and I want to be able to take
I have a asp.net web application and I'm using cache (HttpRuntime.Cache) to save some
I have an ASP.NET web application that is using forms authentication. Everything is configured
I have an ASP.NET web application project which references another project called ModusCore (or

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.