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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:27:09+00:00 2026-05-15T04:27:09+00:00

Stupid Monday morning basic/noob question… Is Page_Load generally called for an ASP.Net MVC app?

  • 0

Stupid Monday morning basic/noob question…

Is Page_Load generally called for an ASP.Net MVC app?

We just have one page, Default.aspx.cs – which only seems to be called for / and not for any sub-paths, so I dont think it is generally called…

Thanks for the reply – to clarify, what I want to do in the Page_Load is the security checks, ie is user logged on/authorised for the page… Sounds like I should do a custom attribute and put it on a Controller base class instead.

Thanks,
Chris

  • 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-15T04:27:09+00:00Added an answer on May 15, 2026 at 4:27 am

    In theory it is, because a view inherrits from ViewPage, which inherrits the events from Page. However it will be the Load event (it probably wont be automatically wired to Page_Load).

    However, you almost certainly don’t want to do this! In a normal MVC application there is no concept of code behind. Views (or anything ‘behind’ them) should not contain logic. This should go into your controller in small applications, or moved out into other layers in larger apps. The only reason you might want to do this is integration with some existing non-MVC apps, but even then it’s very debatable.

    UPDATE:

    For security, yes you are on the right lines with your other suggestions. (You definately don’t want to use Page_Load for this). MVC provides the AuthorizationAttribute out of the box. You can apply it to controller classes (or base classes), and individual actions, and can specify authorised roles. It’s fine for most scenarios. If you wanted to do something custom you could create a custom attribute.

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

Sidebar

Related Questions

Totally stupid question, but I'm writing my first ASP.NET C# web forms application and
Stupid question, but just making sure here: When should I use TCP over HTTP?
Looks like stupid question, but I just dont get it. My entity: public class
Just a stupid question. Provide a code snippet b=a=2 How to extract the value
Stupid nHibernate noob question, but I can't find the answer anywhere ... I have
Stupid question, but why do we need to use 'retain' when declaring a property?
Stupid question, and forgive me for asking, but someone is asking me, and I
Stupid question, this code: <?php $variable = system(cat /home/maxor/test.txt); echo $variable; ?> with file
Me stupid. How can I know which assembly to reference if I just know
Really stupid question, sorry, but I can't find it on google (I'm sure it's

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.