473,748 Members | 8,760 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tilde in URL causing stress to custom HttpHandler

We have an .NET 1.1 application running on 4 2K3 load balanced servers
(using WLBS). IIS has the .NET aspnet_isapi.dl l mapped as a wildcard
application map. The web.config points *.html to a HttpHandler of our
design. This setup serves over a million page views daily with almost no
hassle whatsoever. We have brought a few affiliates onto our system who
have URLs still floating in Google, Y! and other search engines from before
they moved their domains onto our system. Some of these URLs contain the
tilde character (~) in them. Any time someone finds one of their sites in a
search engine and clicks it, they are presented with an ugly HTTP 500 error.
The error is "Invalid file name for monitoring:
'C:\Inetpub\www root\siteroot\~ subfolder'. File names for monitoring must
have absolute paths, and no wildcards."

Does anyone have any insight as to why this is happening? We don't actually
have any physical subdirectories other than /bin and any other subfolder
requests are handled just fine, say oursite.com/test/index.html... that one
works just fine, we don't get any monitoring errors, even though /test/
doesn't really exist.

Thanks for any insight you may be able to provide,
Jared Tullis

Nov 19 '05 #1
9 3319
Hi Jared,

Thanks for your posting. As for the
"Invalid file name for monitoring:
'C:\Inetpub\www root\siteroot\~ subfolder'. File names for monitoring must
have absolute paths, and no wildcards."

exception you mentioned, it is due to the path validation of the
DirectoryMonito r use by ASP.NET runtime. In fact , the asp.net runtime will
add a FileMonitor (monitoring file changes) for each page which has been
requested( the temporary cached dynamic assembly has been generated for
which) so that when any changes happen on those pages' file, the temporary
cached assembly will be invalid and next regenreate new dynamic compiled
assembly. However, when adding a FileMonitor for a certain given page
path, it'll explicitly check the url path such as :

private FileMonitor AddFileMonitor( string file)
{
.........
if (file.IndexOf(' ~') != -1)
{
throw FileChangesMoni tor.CreateFileM onitoringExcept ion(....);
}

........

}

that's why if any user click a link contains the "~" char the asp.net will
throw such a invalid path exception.

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)




Nov 19 '05 #2
Jared, does a Url with the tilde encoded as %7E cause the same issue? I've
been seeing inconsistencies with the encoding/decoding of spaces v. plus
signs in my HttpModule, which I was able to avoid by forcing space encoding
to %20's.

You -might- be able to get around the problem by using an HttpModule and Url
rewriting rather than the HttpHandler.

The other possibility is that the error is occurring within your
HttpHandler. Tildes are used by ASP.NET to resolve file paths to the
virtual directory. I'd look into that approach first, and do some Tracing
in the Handler to see whether the Url is arriving correctly (or in fact
whether the Handler is getting hit at all).

/// M

"Jared Tullis" <tu*****@noemai l.nospam> wrote in message
news:#g******** ******@TK2MSFTN GP10.phx.gbl...
We have an .NET 1.1 application running on 4 2K3 load balanced servers
(using WLBS). IIS has the .NET aspnet_isapi.dl l mapped as a wildcard
application map. The web.config points *.html to a HttpHandler of our
design. This setup serves over a million page views daily with almost no
hassle whatsoever. We have brought a few affiliates onto our system who
have URLs still floating in Google, Y! and other search engines from before they moved their domains onto our system. Some of these URLs contain the
tilde character (~) in them. Any time someone finds one of their sites in a search engine and clicks it, they are presented with an ugly HTTP 500 error. The error is "Invalid file name for monitoring:
'C:\Inetpub\www root\siteroot\~ subfolder'. File names for monitoring must
have absolute paths, and no wildcards."

Does anyone have any insight as to why this is happening? We don't actually have any physical subdirectories other than /bin and any other subfolder
requests are handled just fine, say oursite.com/test/index.html... that one works just fine, we don't get any monitoring errors, even though /test/
doesn't really exist.

Thanks for any insight you may be able to provide,
Jared Tullis

Nov 19 '05 #3
v-******@online.m icrosoft.com (Steven Cheng[MSFT]) confessed in news:x2
#P************@ cpmsftngxa10.ph x.gbl:
Hi Jared,

Thanks for your posting. As for the
"Invalid file name for monitoring:
'C:\Inetpub\www root\siteroot\~ subfolder'. File names for monitoring must
have absolute paths, and no wildcards."

exception you mentioned, it is due to the path validation of the
DirectoryMonito r use by ASP.NET runtime. In fact , the asp.net runtime will add a FileMonitor (monitoring file changes) for each page which has been
requested( the temporary cached dynamic assembly has been generated for
which) so that when any changes happen on those pages' file, the temporary cached assembly will be invalid and next regenreate new dynamic compiled
assembly. However, when adding a FileMonitor for a certain given page
path, it'll explicitly check the url path such as :

private FileMonitor AddFileMonitor( string file)
{
.........
if (file.IndexOf(' ~') != -1)
{
throw FileChangesMoni tor.CreateFileM onitoringExcept ion(....);
}

........

}

that's why if any user click a link contains the "~" char the asp.net will throw such a invalid path exception.

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Steven,

I understand the essence of your comment, i.e., your explanation of what is
happening, but I am searching for meaning (or I am just being thick
tonight.) I want to know why the design is thus.

So, can you explain: Why is the tilde character special?

First, let me understand: are you saying the code in the runtime that sets
up file monitoring attributes special meaning to the tilde? If so, for what
purpose.

I have also experienced this wierd behavior, when a simple 404 error would
suffice. As a matter of fact, I tried to report this anomaly once, but was
put aback by the fact that I had to *pay* M$ to report a bug on their
website (and maybe they'd refund my money if they deemed it fair)!

Here's what I saw: I have a page called ShoppingCart.as px compiled into my
app (with associated .cs file, etc.).

If I attempt to load ShoppingCarts.a spx, (typo) the file does not exist and
I get, predictably, a simple 404 error from the framework.

But, if I attempt ~ShoppingCart.a spx (yet another typo) I get the error the
OP is talking about: "File names for monitoring must have absolute paths,
and no wildcards."

Shouldn't the runtime simply emit a 404 FnF error in this case also? Why is
a leading tilde special?

So, please, again: Why, or rather, what is the purpose of excepting the
tilde in this instance?

Here's a naive question: Where is this "feature" documented?

Thanks, in advance.

-- ipgrunt

Nov 19 '05 #4
Thanks for your reply,

Yes, %7E as well as %3F both cause the error. I have seen ng postings
elsewhere that have indicated that the HttpModule would not help in this
situation as they don't get called either.

As for tracing, I attached my debugger, put a Trace.Write in the very first
line of my HttpHandler and this error appears to be occurring before either
is encountered :-(

Our HttpHandler would happily throw a 404 if it could just get its hands on
the request.

"MWells" <outbound__at_s ygnal.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
Jared, does a Url with the tilde encoded as %7E cause the same issue? I've been seeing inconsistencies with the encoding/decoding of spaces v. plus
signs in my HttpModule, which I was able to avoid by forcing space encoding to %20's.

You -might- be able to get around the problem by using an HttpModule and Url rewriting rather than the HttpHandler.

The other possibility is that the error is occurring within your
HttpHandler. Tildes are used by ASP.NET to resolve file paths to the
virtual directory. I'd look into that approach first, and do some Tracing
in the Handler to see whether the Url is arriving correctly (or in fact
whether the Handler is getting hit at all).

/// M

"Jared Tullis" <tu*****@noemai l.nospam> wrote in message
news:#g******** ******@TK2MSFTN GP10.phx.gbl...
We have an .NET 1.1 application running on 4 2K3 load balanced servers
(using WLBS). IIS has the .NET aspnet_isapi.dl l mapped as a wildcard
application map. The web.config points *.html to a HttpHandler of our
design. This setup serves over a million page views daily with almost no hassle whatsoever. We have brought a few affiliates onto our system who
have URLs still floating in Google, Y! and other search engines from before
they moved their domains onto our system. Some of these URLs contain the tilde character (~) in them. Any time someone finds one of their sites

in a
search engine and clicks it, they are presented with an ugly HTTP 500

error.
The error is "Invalid file name for monitoring:
'C:\Inetpub\www root\siteroot\~ subfolder'. File names for monitoring must
have absolute paths, and no wildcards."

Does anyone have any insight as to why this is happening? We don't

actually
have any physical subdirectories other than /bin and any other subfolder
requests are handled just fine, say oursite.com/test/index.html... that

one
works just fine, we don't get any monitoring errors, even though /test/
doesn't really exist.

Thanks for any insight you may be able to provide,
Jared Tullis


Nov 19 '05 #5
Hi Steven,

So is there a way to bypass that behavior? There is no use for the
FileMonitor since there is no physical path. Maybe this already is or could
be addressed in .NET 2.0? Our HttpHandler would handle the request without
issue if it could just get its hands on the request, but this is happening
before the HttpHandler even gets a chance to weigh in. At least it could
throw a 404 like IPGrunt suggests below so the user isn't totally thrown.
Please let me know if I can bypass this.

Thanks,
Jared

"IPGrunt" <me@privacy.net > wrote in message
news:Xn******** *************** ***********@130 .133.1.4...
v-******@online.m icrosoft.com (Steven Cheng[MSFT]) confessed in news:x2
#P************@ cpmsftngxa10.ph x.gbl:
Hi Jared,

Thanks for your posting. As for the
"Invalid file name for monitoring:
'C:\Inetpub\www root\siteroot\~ subfolder'. File names for monitoring must
have absolute paths, and no wildcards."

exception you mentioned, it is due to the path validation of the
DirectoryMonito r use by ASP.NET runtime. In fact , the asp.net runtime will
add a FileMonitor (monitoring file changes) for each page which has been
requested( the temporary cached dynamic assembly has been generated for
which) so that when any changes happen on those pages' file, the

temporary
cached assembly will be invalid and next regenreate new dynamic compiled
assembly. However, when adding a FileMonitor for a certain given page
path, it'll explicitly check the url path such as :

private FileMonitor AddFileMonitor( string file)
{
.........
if (file.IndexOf(' ~') != -1)
{
throw FileChangesMoni tor.CreateFileM onitoringExcept ion(....); }

........

}

that's why if any user click a link contains the "~" char the asp.net

will
throw such a invalid path exception.

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Steven,

I understand the essence of your comment, i.e., your explanation of what

is happening, but I am searching for meaning (or I am just being thick
tonight.) I want to know why the design is thus.

So, can you explain: Why is the tilde character special?

First, let me understand: are you saying the code in the runtime that sets
up file monitoring attributes special meaning to the tilde? If so, for what purpose.

I have also experienced this wierd behavior, when a simple 404 error would
suffice. As a matter of fact, I tried to report this anomaly once, but was
put aback by the fact that I had to *pay* M$ to report a bug on their
website (and maybe they'd refund my money if they deemed it fair)!

Here's what I saw: I have a page called ShoppingCart.as px compiled into my
app (with associated .cs file, etc.).

If I attempt to load ShoppingCarts.a spx, (typo) the file does not exist and I get, predictably, a simple 404 error from the framework.

But, if I attempt ~ShoppingCart.a spx (yet another typo) I get the error the OP is talking about: "File names for monitoring must have absolute paths,
and no wildcards."

Shouldn't the runtime simply emit a 404 FnF error in this case also? Why is a leading tilde special?

So, please, again: Why, or rather, what is the purpose of excepting the
tilde in this instance?

Here's a naive question: Where is this "feature" documented?

Thanks, in advance.

-- ipgrunt

Nov 19 '05 #6
Hi Jared,

Thanks for your followup. Ok, I'll try consulting some further experts
(ASPNET or iis) to see whether there is any means to workaround this at
asp.net or IIS level. I'll update you when I got any update. Thanks for
your understanding.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #7
v-******@online.m icrosoft.com (Steven Cheng[MSFT]) confessed in
news:MH******** ******@cpmsftng xa10.phx.gbl:
Hi Jared,

Thanks for your followup. Ok, I'll try consulting some further experts
(ASPNET or iis) to see whether there is any means to workaround this at
asp.net or IIS level. I'll update you when I got any update. Thanks for
your understanding.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


I'd sure like to know why and what to do about it also. (same problem at
times, moving linux/unix to IIS).

-- ipgrunt

Nov 19 '05 #8
Hi ,

Seems this problem has be a by design( the dev guys did found the problem )
issue, the asp.net will use the "~" to represent the application root , so
any url contains this will cause the invalid path exception. Also,
currently seems there hasn't been any good approach to workaround this. If
we do need to avoid this, you may need to contact the MS PSS for a single
hotfix.

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #9
v-******@online.m icrosoft.com (Steven Cheng[MSFT]) confessed in
news:xa******** ******@cpmsftng xa10.phx.gbl:
Hi ,

Seems this problem has be a by design( the dev guys did found the problem )
issue, the asp.net will use the "~" to represent the application root , so
any url contains this will cause the invalid path exception. Also,
currently seems there hasn't been any good approach to workaround this. If
we do need to avoid this, you may need to contact the MS PSS for a single
hotfix.

Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Dumb, really dumb!

Maybe M$ folks that write web server code ought to see how users web apps
have deployed with the competition's products? Especially when M$ marketing
folks work hard to convice us 'grandfathered' users to switch over to M$
stuff.

Thanks Steve for following up. Your work is superb!

-- ipgrunt

Nov 19 '05 #10

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

Similar topics

3
3757
by: Michael Iantosca | last post by:
I have a custom attribute that I attach to certain pages in my application and I want to inspect each page request as it is made to see if the custom attribute is attached to the underlying page class. If is attached I want to perform some action. How can I access custom attributes from an HttpModule? I have to pass a target to the System.Attribute.GetCustomAttribute() call to attempt to retrieve the attached attribute. I tried to access...
3
1781
by: Ralf Müller | last post by:
hi all! in my custom HttpHandler HttpContext.Current.Session is not set - why? greetings, ralf
7
2918
by: Adam | last post by:
Im trying to add an httphandler for all *.sgf file extensions. I have developed the handler, 1. installed it into the gac 2. added it to the machine.config: <httpHandlers> <add verb="*" path="*.sgf" type="CustomExtensionHandler, Extenders.CustomExtensionHandler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d831d925597c1031" validate="True"/> </httpHandlers>
8
3900
by: bryan | last post by:
I've got a custom HttpHandler to process all requests for a given extension. It gets invoked OK, but if I try to do a Server.Transfer I get an HttpException. A Response.Redirect works, but I really need to avoid the extra round-trip to the client. I've tried Passing the page name, the full URL, and the instance of the handler class to the Transfer method, but everything gets me the same error 500. Any help would be appreciated.
0
1153
by: Mutley | last post by:
Hi All, I have a custom HttpHandler that handles requests for pages with my custom file extension of sfdl. Within the ProcessRequest method of the custom handler I want then to getthe page. I currently do this by making a call to the method GetCompiledPageInstance of the PageParser class. I have been trying to get information on the advantages\disadvantages of using GetCompiledPageInstance instead of using Server.transfer,...
4
4451
by: =?Utf-8?B?QWxm?= | last post by:
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. --------------------------------------------------------------------------------
1
2028
by: henke.lundin | last post by:
Hello, I am having problems with Server.Transfer(string, bool) in the ProcessRequest method of a custom HTTP handler. I get the "Error executing child request" error message. The page that I am trying to transfer to is mapped to the same custom handler. Does anyone know why this occurs? Does the Server.Transfer method assume that the target page is mapped to the default aspx Page HTTP handler?
0
1044
by: =?Utf-8?B?QW1pc2g=?= | last post by:
Hi All, I have a ASP.NET 1.1 web application with default error page specified in customerror tag in web.config along with error handling code in Application error event in global.asax file. Now if a page(.aspx) that does not exist in the application is mentioned in url ,the application redirects to the custom error page mentioned in customerror tag. But when a aspx whether it is existing or non existing is called with a tilde as prefix...
5
7306
by: Author | last post by:
I followed the example at http://support.microsoft.com/kb/308001/EN-US/ and created my own HttpHandler. Here is the code: using System.Web; namespace MyNameSpace { public class SyncHttpHandler: IHttpHandler
0
8991
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8831
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9374
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9325
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8244
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4607
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4876
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3315
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.