Link to home
Start Free TrialLog in
Avatar of jdhibberd
jdhibberd

asked on

incorrect Error 404 (file not found) from WebRequest on IIS 6

I originally asked this in the ASP zone, but I'm begining to think it's a server configuration issue.

I'm attempting to call an ASP.NET 2.0 aspx file using WebRequest / WebResponse.  The file builds a dynamic style sheet from a given XML file, and I want to be able to save the resulting CSS file as a file.  When I test it on my localhost machine, it works correctly.  Once it's live, it gives an incorrect error 404 (page not found).  I have it sending the URI back in the catch routine, and when I put it into the address bar, it works correctly.  I also have a page that links to the aspx file the same as it would a CSS file.  Again, local it works, live it doesn't.  Finally, I tested the WebRequest with a hard coded Uri pointing to the file on the server.  Locally it worked (the reference page running locally, trying to connect to the file on the server), live it didn't.  

We're running on Windows 2003.  I have found various possibilities, including having WebDav disabled (it isn't), having IIS Lockdown utility run (it isn't), problems with UrlScan utility configuration (not used), and MIME settings.  The last is a possibility - since we are requesting an ASPX file, but returning a content type of "text/css".  

I don't think it's code related, but it's possible, so here's the code I'm using.

        string dir = Server.MapPath("~") + "\\css\\" + (string)ViewState["merchname"];
        CSSInfo csssheet = new CSSInfo(StyleList, imagelist, dir);
        csssheet.CSS_SaveFile();  //creates the XML file from the set variables
        ClearStyles();
        UriBuilder dcssb = new UriBuilder(this.Request.Url.AbsoluteUri.Replace("DonationConfiguration.aspx","donationcss1.aspx"));
        dcssb.Query = "MerchantID=" + (string)ViewState["merchname"];
        Uri dcss = dcssb.Uri;
try
{
        WebRequest webreq = WebRequest.Create(dcss);
        WebResponse webrsp = webreq.GetResponse();
        Stream stream = webrsp.GetResponseStream();
        StreamReader strrdr = new StreamReader(stream);
        StreamWriter strwrt = new StreamWriter(dir + "\\donation.css");
        strwrt.Write(strrdr.ReadToEnd());
        strwrt.Close();
        strrdr.Close();
        webrsp.Close();
}
catch
{
        Response.Write(dcss.ToString());
}
Avatar of Dave_Dietz
Dave_Dietz
Flag of United States of America image

What shows up in the w3svc log for the requests that fail?

Dave Dietz
Avatar of jdhibberd
jdhibberd

ASKER

#Software: Microsoft Internet Information Services 6.0
#Version: 1.0
#Date: 2007-03-27 15:44:26
#Fields: date time s-sitename s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status
2007-03-27 15:44:26 W3SVC1975443634 192.168.2.8 GET /donatelinq4/login.aspx - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 404 0 0
2007-03-27 15:44:35 W3SVC1975443634 192.168.2.8 GET /donatelinq4/merchantlogin.aspx - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:35 W3SVC1975443634 192.168.2.8 GET /DonateLINQ4/WebResource.axd d=KR-vLE3VkzN6O-LQfUETUZSEZXJQqPLDtZV2HHObxxA1&t=633028384777500000 80 -
66.193.142.98
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:51 W3SVC1975443634 192.168.2.8 POST /donatelinq4/merchantlogin.aspx - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 302 0 0
2007-03-27 15:44:51 W3SVC1975443634 192.168.2.8 GET /donatelinq4/MerchantHome.aspx - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:51 W3SVC1975443634 192.168.2.8 GET /DonateLINQ4/WebResource.axd d=X2chWWerXICJKI3WADmGgQ2&t=633028384777500000
80 - 66.193.142.98
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:51 W3SVC1975443634 192.168.2.8 GET /donatelinq4/Background.jpg - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:51 W3SVC1975443634 192.168.2.8 GET /DonateLINQ4/WebResource.axd d=mCoykO7ZWsuRWxLyn8sPXw2&t=633028384777500000
80 - 66.193.142.98
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:51 W3SVC1975443634 192.168.2.8 GET /DonateLINQ4/WebResource.axd d=6DClyjbrkSEzMmMtH4RQag2&t=633028384777500000
80 - 66.193.142.98
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:51 W3SVC1975443634 192.168.2.8 GET /DonateLINQ4/WebResource.axd d=dT3eFAS81aFQnXYqtFMJoo2XAJl4lK-GAZC2s2FhIaQ1&t=633028384777500000 80 -
66.193.142.98
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:51 W3SVC1975443634 192.168.2.8 GET /DonateLINQ4/WebResource.axd d=G_tU9AZCjx0qo-6iXddfEs9K2n7KIw-45hRQeVSoJ4I1&t=633028384777500000 80 -
66.193.142.98
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:51 W3SVC1975443634 192.168.2.8 GET /donatelinq4/banner.jpg - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:51 W3SVC1975443634 192.168.2.8 GET /DonateLINQ4/WebResource.axd d=E7SSKcoyTzSew7I28vGL8RFCIEeHs43vPzxQeGQ0H101&t=633028384777500000 80 -
66.193.142.98
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:51 W3SVC1975443634 192.168.2.8 GET /donatelinq4/MerchantLanding.aspx - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:54 W3SVC1975443634 192.168.2.8 POST /donatelinq4/MerchantHome.aspx - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:54 W3SVC1975443634 192.168.2.8 GET /donatelinq4/DonationConfiguration.aspx - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:54 W3SVC1975443634 192.168.2.8 GET /donatelinq4/css/FChase/donation.css - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 404 0 2
2007-03-27 15:44:54 W3SVC1975443634 192.168.2.8 GET /donatelinq4/Transparent.gif - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:54 W3SVC1975443634 192.168.2.8 GET /donatelinq4/ColorPickerMap.jpg - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:54 W3SVC1975443634 192.168.2.8 GET /donatelinq4/DropDown.gif - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:54 W3SVC1975443634 192.168.2.8 GET /donatelinq4/ - 80 -
66.193.142.98
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 403 14 5
2007-03-27 15:44:57 W3SVC1975443634 192.168.2.8 POST /donatelinq4/DonationConfiguration.aspx - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:45:00 W3SVC1975443634 192.168.2.8 POST /donatelinq4/DonationConfiguration.aspx - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 200 0 0
I suspect that it's the two lines towards the end.

2007-03-27 15:44:54 W3SVC1975443634 192.168.2.8 GET /donatelinq4/ - 80 -
66.193.142.98
Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 403 14 5

Nowhere does it mention the exact file that it's supposed to be getting.  These are the only lines though that I can't account for based on the filenames.  It almost appears that it's trying to pull up the directory first.  If I'm reading this right, the 403 14 indicates that it's preventing access to the folder.  What I don't understand is why it's not going directly to the file itself.
Ok, aparently that wasn't the right log file.  I don't have a copy of the correct one, but it is giving a generic 500 0 0 error.  The event viewer only showed 30005 30006 and 30007 (unhandled exceptions).  
2007-03-27 15:44:26 W3SVC1975443634 192.168.2.8 GET /donatelinq4/login.aspx - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 404 0 0

and

2007-03-27 15:44:54 W3SVC1975443634 192.168.2.8 GET /donatelinq4/css/FChase/donation.css - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.
NET+CLR+2.0.50727) 404 0 2

are the only two 404 responses you are showing in that log file.

Do either of those two files actually exist?  The subcode of 0 indicates this is a true 404 and the file isn't where you are looking for it.

Dave Dietz
Neither of those files exist, but that's expected.  The first one was done on purpose to see what a true 404 should return.  The second is a link to a CSS file that would have been previously created.  I haven't put in a check to see whether it exists or not, since the page ignores it if it doesn't.

In running some tests today, what we were seeing in the logs are 500.0 errors.  The page still showed a 404 error though.  And none of the log entries mention the actual file it is supposed to be pulling up (donationcss.aspx).  The only error that shows up in the current log (other than the 404 from the missing style sheet) is this 500 error.

2007-03-27 20:48:40 W3SVC1975443634 SVCTAG-7X3K5C1 192.168.2.8 POST/donatelinq4/merchantadministration/DonationConfiguration.aspx - 80 -66.193.142.98 HTTP/1.0Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+1.1.4322;+.NET+CLR+2.0.50727) ASP.NET_SessionId=cpnk5vyxlkmlqi20hkrezg45http://dev.thecashlinqgroup.com/donatelinq4/merchantadministration/DonationConfiguration.aspx dev.thecashlinqgroup.com 500 0 0 6214 7164 78
Do you have custom errors configured in the web.config?

It looks like the ASPX page is encountering some issue and is throwing an error.

Have you tried debugging it in Visual Studio and stepping through it to see where the error occcurs?

Dave Dietz
I don't have custom errors set up.  As for the ASPX page having errors, I've run it locally without any problem.  It's only on the server that it does not work.  Is there a way to debug it on a live server?

Thanks for your help on this.  It's a weird one.  I've seen many similar issues, but they either aren't exactly the same, or they are and no one bothered to post the solution (if any was found).
As an update, I have a workaround for this.  Instead of sending a web request and capturing the response, I have it calling the page from a server execute, and filtering the response stream, sending the css portion to the file, and the rest back to the screen.  It works and should be ok for what I need,  but I would still like to know why the original doesn't work, and if possible get it to work, in case I run into this in the future.  
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial