Solved

based class method is not getting called

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

740 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