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 8601765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:55:11+00:00 2026-06-12T01:55:11+00:00

I have a c# web application on i.e. http://mysite.com User opens his browser and

  • 0

I have a c# web application on i.e. http://mysite.com

User opens his browser and types http://mysite.com/anywrongpath

Which I want to do is to get the “exact” url ( /anywrongpath ) and THEN redirect that user to i.e. /MainPage.aspx

I think I can handle redirection with:

protected void Application_Error(object sender, EventArgs e)
{
    HttpException httpException = Server.GetLastError() as HttpException;
    if (httpException.ErrorCode == 404)
       Response.Redirect("/MainPage.aspx");
}

However, I have no idea how to handle the retrieve process of typed url. I made a research of “Sessions” , “Request.ServerVariables” , “Request.Url” etc but I couldnt solve the problem.

I am open for any idea how to solve it, and really glad if you give tiny code samples, thanx

Murat

  • 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-12T01:55:13+00:00Added an answer on June 12, 2026 at 1:55 am

    Edit your web.config file and put something like this in the system.web section

    <customErrors mode="RemoteOnly" defaultRedirect="Error.aspx">
        <error statusCode="404" redirect="MainPage.aspx" />
    </customErrors>
    

    When your user types an address like mysite.com/non-existant, IIS redirects him to mysite.com/MainPage.aspx?aspxerrorpath=/non-existant

    This way, you can get the Request.QueryString["aspxerrorpath"]

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

Sidebar

Related Questions

I have a Web application ( http://www.holidaystreets.com ), it has around 120,000+ pages. Whenever
I have a J2EE application with a web service which goes like http://servername/service?task=getFile&id=25 How
I've got an ASP.NET MVC 3 web application that lives on server 1: http://www.mysite.com
I am using a javax.servlet.http.HttpServletRequest to implement a web application. I have no problem
I have web application which we deployed in a production . We have separate
I have web application of which major part is javascript. I request images from
I have a web application that will be used on iPhones, and want to
We have a custom master page that is deployed to the MySite web application
I have a .NET web application in which I am developing three separate websites
I have web application written in java using Eclipse. It has just one servlet

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.