Solved

based class method is not getting called

Posted on 2014-07-24
1
499 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create a Dropdown list with sub group 10 43
Read top line from CSV file 14 58
How does GeoJson relates to Leaflet and Mapbox? 4 49
Textbox autocomplete using jquery in asp.net 13 49
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 …
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 …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

739 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