Aaron Johnson Now with 50% less caffeine!

Posted
14 July 2005 @ 10pm

Tagged
.NET, Systems Administration

ASP.NET: The resource cannot be found.

Spent some time today buried in IIS trying to figure out why an ASP.NET application would throw the following error message for every single page that existed in an application within a website:

Server Error in ‘/myapp’ Application.
—————————————————-
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested Url: /myapp/default.aspx
—————————————————-
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032

Googled for “resource cannot be found” and found this link on the third result page. In it Jarrett mentions that he solved the problem by reading this experts-exchange.com question which suggests setting up the application as a Virtual Directory in IIS instead of simply marking the folder in the website as an application, which of course solved the problem for me as well. Since a picture is worth a thousand words, here’s the difference between a Virtual Directory (which is an application in and of itself) and directory in IIS that has been marked as an application:

virtual_directory.gif

directory.gif

My suspicion is that the problem has to do with ASP.NET configuration inheritance settings with Virtual Directories not inheriting from parent directories like a folder marked as an application would, but there isn’t much to go on. Any Microsoft IIS experts out there want to talk about the difference between a Virtual Directory and a folder that has been marked as an application from a configuration standpoint?


33 Comments

Posted by
Luke
12 August 2005 @ 2pm

That is totally random, but it worked, thanks.


Posted by
Ben Joyce
23 August 2005 @ 12pm

Yeah, this works… thanks for the tip!


Posted by
pholpar
5 September 2005 @ 10am

Try this, it solved the issue for me:

You may receive error messages when you browse or try to debug an ASP.NET application after you install security update 887219 (MS05-004)

http://support.microsoft.com/kb/894670/en


Posted by
Stonie
30 November 2005 @ 7pm

I have had this happen a few times now, this fix didn’t work for my case. Each time I have ended up reinstalling IIS, to solve the problem. Grrrrrr. My guess is the metabase is screwy.


Posted by
matt
20 December 2005 @ 9am

Thanks! This post save a lot of headaches for me.


Posted by
onepoket
22 December 2005 @ 11am

If you are still having problems after trying the MSKB article this may help. My problem did include the trailing backslash but it wasnt at the virtual dir or folder level. If you have a problem with a virtual dir go in to the properties and if you have an ASP.NET tab click on it, look at the “file location” it should look something like this: c:\inetpub\wwwroot\somedir\web.config, if it has 2 slashes after the wwwroot like this: c:\inetpub\wwwroot\\somedir\web.config thats your problem. Go to the properties of the website that is the parent of your virtual directory and go to the home tab, take out the trailing slash there and all your virtual dir problems should be fixed.

-onepoket


Posted by
Conrad
21 January 2006 @ 10pm

Hey, this is a great tip. I had tried just about everything until I found your page. My problem was fixed by removing the final trailing slash from the home directory of my root web site, “C:\InetPub\wwwroot\”.

-Conrad


Posted by
Knut Hamang
26 January 2006 @ 5am

Great tip. I had the problem with home directory having a final trailing slash. Thanks for the tip, onepocket


Posted by
Steve
16 February 2006 @ 2pm

I am having the same problem in vs2005 in asp.net 2 environment. I am not using IIS. Any idea?


Posted by
mike
6 March 2006 @ 1am

WIN XP PRO - SQL 2K - VS 2003 .. Worked like a charm. Thanks.. Strange..


Posted by
Jereme Guenther
3 April 2006 @ 2pm

Bummer, none of these suggestions worked for me. The bad thing is I know that I have had this problem before, but I can’t remember what I did to fix it. I probubly wrote it down but what are the odds that I will be able to find where I put it until I have already solved the problem.


Posted by
Mark
6 April 2006 @ 11am

This worked for me.

Also removing the trailing slash from the “Default Web Site” home directory fixed the problem so I don’t have to use the virtual directory fix.


Posted by
greg
16 April 2006 @ 2pm

Hi, removing the last slash from

C:\InetPub\wwwroot\

(Internet Services Manager -> “Default Web Site” Properties -> Tab “Home Directory”) fixed the issue. Thanks a lot!


Posted by
Chiel S
24 April 2006 @ 1pm

I had the same problem but none of the above solutions worked. I fixed the problem as followed:

My home directory of my webserver was “W:\” (the root of a partition on my hdd called webserver). When i created a dir: W:\webserver and assigned that directory as root to the webserver, it suddenly worked!

I seems that asp.net 2.0 can’t handle database file path’s to a partition of hdd, but only a direct directory, or something like that ;) Anyway, if you have the config as i had before, try this!


Posted by
Jesse
3 November 2006 @ 8am

Worked for me as well.


Posted by
David
6 December 2006 @ 10am

I had the same problem as Chiel. I can confirm that by using instead of your root partition, in my case, E: drive, you should put in a folder so it would be E:\webserver\. By doing this I was able to create my virtual directory and web application at the same time and it was accesible afterwards through my browser. I just backed up my current web site and restored it to E:\webserver\ then configured my Home directory to point to that location, afterwards I created my virtual directory and web application by right clicking the Default Web Site -> New -> Virtual Directory and following the steps in the wizard.

This is the error that I had.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.

Hope this helps others.


Posted by
JJ
19 January 2007 @ 4pm

Can someone help? None of the above worked for me.

I did a web setup deployment in .net 2005, and ran the MSI on the client’s machine.

Everything seemed fine, except that he gets the 404 over and over again, no matter what I do.

I’ve tried: removing all trailing backslashes, uninstalling .net platforms 1.0 and 1.1, -ga (grant access) option to metabase for aspnet, client, and anonymous IUSR, setting it up as a virtual directory (MSI deploys it already as such), I even gave everyone full control over the folders… nothing.

.NET 2005 does deploy via assemblies in the bin, with the aspx pages having that COMPILED extension, pdbs and dlls, etc. Does this have anything to do with it?

Help, please and thanks,
JJ


Posted by
Andrew
8 March 2007 @ 2pm

I had the same problem, and it took hours to discover that VS 2005 had added the element to the web.config. According to MSDN, “If False, the application is effectively turned off.” Brilliant.


Posted by
Andrew
9 March 2007 @ 7am

Sorry, that should read “VS 2005 had added the element <httpRuntime enable=’False’/>”

Here is the description:
http://msdn2.microsoft.com/en-us/library/e1f13641.aspx


Posted by
sourabh shankar
9 March 2007 @ 10pm

this post is the REAL troubleshooter. i have tried everything until i removed the trailing slash from the root directory where the .net project is hosted. and it worked like there is no tomorrow. i tip works 100%. microsoft should put a link to this page instead of giving scrappy work-arounds. gtg now, i have other exceptions to debug. thanx once again :)


Posted by
Eliseu Martinho
31 July 2007 @ 7am

Hey aJohnson. I’ve tried your solution to solve a similar problem of mine but it didn’t work.:/ Yet I got another workaround. I’ve followed your approach (took the last slash from the Local Path string). Then in the WebSite folder, where you have your WebApplication, I went to properties->Web Site and set the IP Address to the computer IP. I Also checked if the ASP.NET tab was in the correct version of ASP.NET for the application. And that was it.

Hope this helps.


Posted by
crunch
3 August 2007 @ 9pm

Modify the web.config.
add before the node. maybe can resolve this problem.


Posted by
crunch
3 August 2007 @ 9pm

httpRuntime enable=true


Posted by
Paul
27 November 2007 @ 4am

Hi Aaron thanks for that - saved me tearing my hair out - the removing trailing slash worked for me.


Posted by
Falk
6 December 2007 @ 3am

Although this page dates back to summer 2005, people are still posting to it, so I suppose this issue is still bugging developers. I came across this page because I also got that completly useless error message.

I found another cause for the problem.

Problem description:

As above, when requesting an .aspx page, you get
“The resource cannot be found. (…) HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.”,
although the page is clearly there.

In my case the cause was:

For project design reasons, I subclassed the System.Web.UI.Page class. In the constructor, I tried to System.IO.File.OpenRead(”myapp.config”), which did not exist. The exception is uncaught. In this scenario, I did not see the exception, but instead got the 404 resource not found error. Catching the exception or moving the File.OpenRead to somewhere else in the code solves the issue.


Posted by
Jessica
3 April 2008 @ 1am

The above-mentioned solutions do not stop this error from prompting. What am I supposed to do?


Posted by
Scott
23 April 2008 @ 3am

I found another solution to the problem you might be facing. As obvious as this is, hopefully it will help someone out there.

Note: I don’t have a virtual directory, and I didn’t have the extra slash. I setup my site in IIS as a “new website”.

When you add the website to IIS you are prompted to add a host header for the site. Usually I put two domains in the list… with and without the “www”. So, http://www.domainname.com and domainname.com. When I added the website I was having a problem with I forgot to add the “www” version… but when I tested the site I typed the www in the URL. I also explicitly referenced the default.aspx page in the URL as well. Since I was navigating to the URL that wasn’t in the host header definition for the new site it was resolving to the “Default Website” in IIS which didn’t have “default.aspx”.

All in all, be sure to have your host headers correct. Good luck!


Posted by
Kadir
6 August 2008 @ 3am

Hi, I am debugging my application localy on Visual Studio 2005’s embedded server. How can I fix the problem?

Thanks a lot


Posted by
Satish
6 November 2008 @ 10am

Amazing, Take a bow. This is wonderful. It worked for me.

Thanks a lot


Posted by
Geiger
9 December 2008 @ 11am

I was getting this on a directoy of my one website. I first checked the directory security and that was fine. I checked the ISAPI filters and the Web.Config to make sure there weren’t any redirects in there. The problem was that I also had SQL Server Reporting Services installed and I was using the “Reports” directory. I just renamed the Reports directory to Report.


Posted by
Rob
22 April 2009 @ 1pm

Saved my day. Thanks.


Posted by
Rattan
18 August 2009 @ 3am

IT is nice answer BUT I find another problem

Of spaces like Response.Redirect(”Default.aspx ? Val1 =” + ((Control)sender).ID);
should be written as

(”Default.aspx?Val1=” +((Control)sender).ID);
and I have waisted lots of hours for this problem because the problem “The resource not found” is shown Response page.


Posted by
John L
17 September 2009 @ 10am

@Andrew … dude you are a life saver … vs2008 did this to my application as well … WOOT! works now :)


Leave a Comment

Trailing Slashes, IIS and F5 / Big-IP Links: 7-11-2005