473,394 Members | 1,701 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

App does not redirect to custom error page with ~(tilde) in URL

Hello all,

I am having trouble dealing with ~(tilde) in my .Net 1.1 web application,
specially when it comes through the URL. For example, when someone requests
the following URL: www.mysite.com/~mypage.aspx, my web application will
through the following error (with custom errors turned off):
Server Error in '/' Application.
--------------------------------------------------------------------------------

Invalid file name for monitoring: 'dir to my site\~mypage.aspx'. File names
for monitoring must have absolute paths, and no wildcards.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Web.HttpException: Invalid file name for
monitoring: 'dir to my site\~mypage.aspx'. File names for monitoring must
have absolute paths, and no wildcards.
I have custom errors set to On and defaultRedirect pointed to a custom error
page in my web.config file. Unfortunately, this error seems to be bypassing
it.

I have code in the Application_Error event to log all errors and this error
does get logged. So I set up a regex that parses the URL and if it detects a
~, it will do a server.transfer to my custom error page. This works if the
above-mentioned URL is requested, however does not work if anyone appends any
querystring parameters behind it. For example:
www.mysite.com/~mypage.aspx?hit= When this URL is requested, I get the same
error as above and this time is does not go through the Application_Error
event since I do not have a record of this error!

Since this is application testing, I have no control over what the tester
will enter on the site so I cannot ask them to not request a URL with a ~ in
it.

What am I doing wrong in trying to catch this error. Is there another
location I'm missing an error handler (apart from web.config default redirect
and Application_Error in Global.asax)?

The site is deployed on IIS 6 with .Net framework 1.1.4322

Thanks in advance,
Alf
Mar 13 '07 #1
4 4406

"Alf" <Al*@discussions.microsoft.comwrote in message
news:56**********************************@microsof t.com...
Hello all,

I am having trouble dealing with ~(tilde) in my .Net 1.1 web application,
specially when it comes through the URL. For example, when someone
requests
the following URL: www.mysite.com/~mypage.aspx, my web application will
through the following error (with custom errors turned off):
Server Error in '/' Application.
--------------------------------------------------------------------------------

Invalid file name for monitoring: 'dir to my site\~mypage.aspx'. File
names
for monitoring must have absolute paths, and no wildcards.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about
the error and where it originated in the code.

Exception Details: System.Web.HttpException: Invalid file name for
monitoring: 'dir to my site\~mypage.aspx'. File names for monitoring must
have absolute paths, and no wildcards.
I have custom errors set to On and defaultRedirect pointed to a custom
error
page in my web.config file. Unfortunately, this error seems to be
bypassing
it.

I have code in the Application_Error event to log all errors and this
error
does get logged. So I set up a regex that parses the URL and if it detects
a
~, it will do a server.transfer to my custom error page. This works if the
above-mentioned URL is requested, however does not work if anyone appends
any
querystring parameters behind it. For example:
www.mysite.com/~mypage.aspx?hit= When this URL is requested, I get the
same
error as above and this time is does not go through the Application_Error
event since I do not have a record of this error!

Since this is application testing, I have no control over what the tester
will enter on the site so I cannot ask them to not request a URL with a ~
in
it.

What am I doing wrong in trying to catch this error. Is there another
location I'm missing an error handler (apart from web.config default
redirect
and Application_Error in Global.asax)?
Why tilde (~) should not be used in Web addresses (URLs)
http://www.cs.tut.fi/~jkorpela/tilde.html
Mar 13 '07 #2
Hello Alexey,

Thank you for the interesting article. I have no use for tilde on my site
but I am not in control of what the site auditor requests during his tests.

The article recommends escaping tildes in the URL. Where in my .Net
application should I be doing that? In the Begin_Request event?

Regards,
Alf

"Alexey Smirnov" wrote:
>
"Alf" <Al*@discussions.microsoft.comwrote in message
news:56**********************************@microsof t.com...
Hello all,

I am having trouble dealing with ~(tilde) in my .Net 1.1 web application,
specially when it comes through the URL. For example, when someone
requests
the following URL: www.mysite.com/~mypage.aspx, my web application will
through the following error (with custom errors turned off):
Server Error in '/' Application.
--------------------------------------------------------------------------------

Invalid file name for monitoring: 'dir to my site\~mypage.aspx'. File
names
for monitoring must have absolute paths, and no wildcards.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about
the error and where it originated in the code.

Exception Details: System.Web.HttpException: Invalid file name for
monitoring: 'dir to my site\~mypage.aspx'. File names for monitoring must
have absolute paths, and no wildcards.
I have custom errors set to On and defaultRedirect pointed to a custom
error
page in my web.config file. Unfortunately, this error seems to be
bypassing
it.

I have code in the Application_Error event to log all errors and this
error
does get logged. So I set up a regex that parses the URL and if it detects
a
~, it will do a server.transfer to my custom error page. This works if the
above-mentioned URL is requested, however does not work if anyone appends
any
querystring parameters behind it. For example:
www.mysite.com/~mypage.aspx?hit= When this URL is requested, I get the
same
error as above and this time is does not go through the Application_Error
event since I do not have a record of this error!

Since this is application testing, I have no control over what the tester
will enter on the site so I cannot ask them to not request a URL with a ~
in
it.

What am I doing wrong in trying to catch this error. Is there another
location I'm missing an error handler (apart from web.config default
redirect
and Application_Error in Global.asax)?

Why tilde (~) should not be used in Web addresses (URLs)
http://www.cs.tut.fi/~jkorpela/tilde.html
Mar 13 '07 #3

"Alf" <Al*@discussions.microsoft.comwrote in message
news:2D**********************************@microsof t.com...
The article recommends escaping tildes in the URL. Where in my .Net
application should I be doing that? In the Begin_Request event?
In principle, you can use Application_Error event

if (Request.Url.ToString().IndexOf("~") 0)
{
Context.ClearError();
Context.RewritePath("HttpError404.aspx");
return;
}
Mar 13 '07 #4
"Alexey Smirnov" wrote:
>
"Alf" <Al*@discussions.microsoft.comwrote in message
news:2D**********************************@microsof t.com...
The article recommends escaping tildes in the URL. Where in my .Net
application should I be doing that? In the Begin_Request event?

In principle, you can use Application_Error event

if (Request.Url.ToString().IndexOf("~") 0)
{
Context.ClearError();
Context.RewritePath("HttpError404.aspx");
return;
}
I added the code above and my application does catch some tilde generated
errors now. For example, for the URL http://www.mysite.com/~mypage.aspx, the
code above will redirect to my custom error page but if I have this URL
http://www.myside.com/~mypage.aspx?qt=, then the code above does not pick up
the tilde in the URL. Why is that happening?
Mar 14 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: apngss | last post by:
I want to know how to redirect 404 error to custom error page? For example, if test.html doesn't exist and the user type http://www.myserver.com/test.html, it will show my custom error page,...
3
by: Adie | last post by:
Hi, Ive recently updated our companies site and have been looking at the server logs and it appears a bunch of people are entering the site at specific pages that no longer exist. I wonder if...
1
by: Mukund Patel | last post by:
Hi friends, I have implemented custom error handling at page level and application level. If there is any syntax error in my aspx class file it will redirect to error page when I run the page....
7
by: Joe Rigley | last post by:
Hi, I have a custom class with a public method. I want to perform a repose.redirect if an error occurs in the public method GetUserRoles. Unfortunately, Visual Studio 2003 is throwing an error...
15
by: dee | last post by:
Hi, I'm curious why MS decided to have Transfer hide the target page's url invisible? Any guesses ? Thanks. Dee.
0
by: Stuart Palmer | last post by:
Hi everyone, I'm trying to look for an asp equivilent of .htaccess that is used on apache servers but for use with asp. I am doing a website and moving lots of files into a single directory to...
1
by: Dylan Parry | last post by:
Hi folks, I've been searching for this for some time, but all I seem to be able to find are pages describing how to set custom error pages, whereas what I want to do is simply redirect the user...
3
by: wwwmike | last post by:
For some reasons my HTTP Redirect for 404 errors does not work for certain files like .gif .jpg on IIS Version: 5.1, but it works perfectly with the VisualStudio2005 internal webserver ...
5
by: rote | last post by:
I'm using ASP.NET 2.0 and i have copied and pasted the code below to my Global.asax file but it desn't trap the error I want to trap the 401 access denied void Application_Error(object sender,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.