Solved

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

Posted on 2011-02-11
2
275 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 40

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SSRS ReportViewer report timeout 7 101
DataGridView Events ? 3 37
How do ASP.NET and MVC work together? 4 27
Filename to be appended with DateTimeof Download 3 44
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

911 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

25 Experts available now in Live!

Get 1:1 Help Now