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

  • SEARCH
  • Home
  • 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 4573260
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:45:38+00:00 2026-05-21T19:45:38+00:00

I use C# Asp.Net and EF 4. I have a scenario like MasterPage and

  • 0

I use C# Asp.Net and EF 4.

I have a scenario like MasterPage and DetailsPage.

So from my MasterPage I pass a variable as a QeryString to the DetailsPage, the DetailsPage will show up details for a specifc item in my DataBase.

I need to check the validity for my QueryString, in details I need:

  • Check if is Null, Empty or White Spaces.
  • Check if is NOT of type INT (just numbers not any letters).
  • Check if the Object NOT exists in my DB.

In case if Check result True, I will redirect the User.

At the moment I wrote this script. It is works but I would like to know if you know a better approch/code to solve this.

Also I would like to know if make sense to have this logic on every time the page Load, or would be enought us just on !Page.IsPostBack.

Thanks once again for your support guys!

   protected void Page_Load(object sender, EventArgs e)
    {
        #region Logic Check Query String.

        // Query String is Null or Empty.
        if (string.IsNullOrWhiteSpace(ImageIdFromUrl))
            RedirectToPage();

        // Query String is not valid Type of INT.
        int ImageId;
        bool isInt = Int32.TryParse(ImageIdFromUrl, out ImageId);
        if (isInt)
        {
            // Check if a valid Object request exist in Data Source.
            using (CmsConnectionStringEntityDataModel context = new CmsConnectionStringEntityDataModel())
            {
                if (!context.CmsImagesContents.Any(x => x.ImageContentId == ImageId))
                {
                    RedirectToPage();
                }
            }
        }
        else
            RedirectToPage();

        #endregion

    }
  • 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-05-21T19:45:39+00:00Added an answer on May 21, 2026 at 7:45 pm

    You don’t need to check it on every postback, only on a full page load. The query string is not sent to the server on postbacks.

    I suggest you move all the query string validation logic to separate functions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a ASP .Net application whereby we use Log4Net to log details within
Scenario I have an application using asp.net Master Pages in which I would like
The Scenario: I have an ASP.Net webpage which I intend to use for letting
I use ASP.NET and have a label control on my page, which I fill
I use ASP.NET and have a Button and a CustomValidator, which has to validate
I have been attempting to use ASP.NET MVC remote validation for username login access
I have set up my website to use ASP.NET Membership. it all works fine
I'm trying to use ASP.net profiles I've followed some instructions which means I have
I use consomcontrols.grid on asp.net.I have a width problem specially on IE on page.
how can i use request.querystring in asp.net.i have a linkbutton and this is in

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.