Solved

based class method is not getting called

Posted on 2014-07-24
1
496 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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 Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

786 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