Solved

Which function should I use to test page permission on a Page Load?

Posted on 2011-02-11
2
264 Views
Last Modified: 2012-05-11
Should I check permissions on Page_Load() as I have done in the code snippet below?  Should I use Page_Init()? Both functions? Or some other place?

I want to redirect to a failure page when the user does not have permission.

newbieweb

protected void Page_Init(object sender, EventArgs e)
        {
            table = DynamicDataRouteHandler.GetRequestMetaTable(Context);
            FormView1.SetMetaTable(table);
            DetailsDataSource.EntityTypeFilter = table.EntityType.Name;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!RDDBAdminDataStore.User.IsAdministrator)
            {
                Response.Redirect("AccessDenied.aspx");
            }
            Title = table.DisplayName;
            DetailsDataSource.Include = table.ForeignKeyColumnsNames;
        }

Open in new window

0
Comment
Question by:newbieweb
2 Comments
 
LVL 39

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 34874183
Definitely not in both.  


Page_Load is fine . . . see the differences here.
http://fuchangmiao.blogspot.com/2008/03/pageinit-vs-pageload.html
0
 

Author Closing Comment

by:newbieweb
ID: 34874199
Thanks!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now