Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8199201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:07:21+00:00 2026-06-07T06:07:21+00:00

I have a Catcha value( Security Code ) that is store in Session on

  • 0

I have a Catcha value( Security Code ) that is store in Session on PageLoad and that is going to be used when user clicks the search button. If the User is IDLE for more than 20 Min the value of Session is get expired. And when user clicks on Search Button. It Throws error ” Object Reference Not Set To an Instance of an Object”.

On PageLoad:

 if (!IsPostBack)
        {
            Session["CaptchaImageText"] = new RandomGen().GenerateRandomCode();

        }

On SearchButtonClick event:

if (SecurityCodeTextBox.Text.Trim() == Session["Captcha"].ToString())
        {
            return true;
        }
        else
        {
            return false;
        }

Here i get error “Object Reference Not Set To an Instance of an Object”.
i have also checked wheather the Session[“Captcha”]!= null. But still it shows the same error.

How to Redirect or show a message that “Session Timeout !Visit again” and close the Browser.

Thanks in Advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T06:07:23+00:00Added an answer on June 7, 2026 at 6:07 am

    TO close the browser, you need a client-side script… there is no way to do it by server-side, so, you can generate some javascript calling window.close();. For th message error, check if the Session[] is not null, if you call some method of this and it’s null, you will get this kind of exception. Try something like this:

    if (Session["Captcha"] == null)
    {
       Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Session Timeout! Visit again.'); window.close();", true);
       return false;
    }
    
    return (SecurityCodeTextBox.Text.Trim() == Session["Captcha"].ToString());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code that uses methods from the SSPI dll (security.dll) via P/Invoke, which
I have never used Try-catch in my code before, but now I need to
I have this function here that assembles an API call to eBay. It used
I have A WCF service that has a class that inherits System.Web.Security.RoleProvider. In this
I have an application that uses Spring Security to control access to pages, to
I have the store procedure for validating user id and password like this PROCEDURE
I have used CAPTCHA on my various web sites in the standard manner where
In my Java code, I occasionally run into situations where I have to catch
I have a Try Catch in my code. I would like to know if
What have people used to catch, log, and report multiple data validation errors at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.