Solved

based class method is not getting called

Posted on 2014-07-24
1
433 Views
Last Modified: 2014-07-24
I have created a base "WebForm" class which is derived from asp.net Page class.
Now I want all my web pages to be dervied from this base class "WebForm".

So I did this
 public partial class Index : WebForm
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }
    }
   
but when  I am running the application then asp.net is not calling "WebForm" "Page_Load" method.

I am not sure what wrong I am doing here


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;

namespace xyz
{
    public class WebForm: Page    
    {                
        private void Page_Load(object sender, System.EventArgs e)
        {            
            string strFile = Request.Url.GetLeftPart(UriPartial.Path);

            //-- For every file except the Login screen Validate the Login.
            if ((strFile.ToLower().IndexOf("SignIn") > 0))
            {
                //-- Do nothing.
            }
            else if (Session.IsNewSession | (MySession.IsExists == false))
            {
                Response.Redirect("SignIn");
            }
            else
            {
                if (MySession.CurrentUser == null)
                {
                    Response.Redirect("SignIn");
                }
            }
        }

        protected override void OnError(EventArgs e)
        {
            if (!(Request.Url.Host == "localhost"))
            {
                // At this point we have information about the error
                HttpContext ctx = HttpContext.Current;
                Exception exception = ctx.Server.GetLastError();
                
                //Try to send an error email
                try
                {
                    EmailBuilder.SendErrorMail(exception,ctx.Request);
                }
                catch
                {
                }
                ctx.Response.Write("We're sorry, there was an error. Thanks for noticing - we're going to fix it up and have things back to normal soon.");
                
                // To let the page finish running we clear the error                
                ctx.Server.ClearError();
                base.OnError(e);
            }
        }
    }
}

Open in new window

0
Comment
Question by:yadavdep
1 Comment
 
LVL 4

Accepted Solution

by:
Chris Watson earned 190 total points
ID: 40216339
In the Page_Load method in your Index page are you calling base.PageLoad() ?

public partial class Index : WebForm
{
    protected void Page_Load(object sender, EventArgs e)
    {
        base.Page_Load(sender, e);
    }
}

Open in new window

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
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.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

930 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

14 Experts available now in Live!

Get 1:1 Help Now