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["merchna me"];
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.Ur l.Absolute Uri.Replac e("Donatio nConfigura tion.aspx" ,"donation css1.aspx" ));
dcssb.Query = "MerchantID=" + (string)ViewState["merchna me"];
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.ReadTo End());
strwrt.Close();
strrdr.Close();
webrsp.Close();
}
catch
{
Response.Write(dcss.ToStri ng());
}
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["merchna
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.Ur
dcssb.Query = "MerchantID=" + (string)ViewState["merchna
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.ReadTo
strwrt.Close();
strrdr.Close();
webrsp.Close();
}
catch
{
Response.Write(dcss.ToStri
}
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;+M SIE+6.0;+W indows+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;+M SIE+6.0;+W indows+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.a xd d=KR-vLE3VkzN6O-LQfUETUZSE ZXJQqPLDtZ V2HHObxxA1 &t=6330283 8477750000 0 80 -
66.193.142.98
Mozilla/4.0+(compatible;+M SIE+6.0;+W indows+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;+M SIE+6.0;+W indows+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;+M SIE+6.0;+W indows+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.a xd d=X2chWWerXICJKI3WADmGgQ2& t=63302838 4777500000
80 - 66.193.142.98
Mozilla/4.0+(compatible;+M SIE+6.0;+W indows+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.jp g - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+M SIE+6.0;+W indows+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.a xd d=mCoykO7ZWsuRWxLyn8sPXw2& t=63302838 4777500000
80 - 66.193.142.98
Mozilla/4.0+(compatible;+M SIE+6.0;+W indows+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.a xd d=6DClyjbrkSEzMmMtH4RQag2& t=63302838 4777500000
80 - 66.193.142.98
Mozilla/4.0+(compatible;+M SIE+6.0;+W indows+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.a xd d=dT3eFAS81aFQnXYqtFMJoo2X AJl4lK-GAZ C2s2FhIaQ1 &t=6330283 8477750000 0 80 -
66.193.142.98
Mozilla/4.0+(compatible;+M SIE+6.0;+W indows+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.a xd d=G_tU9AZCjx0qo-6iXddfEs9K 2n7KIw-45h RQeVSoJ4I1 &t=6330283 8477750000 0 80 -
66.193.142.98
Mozilla/4.0+(compatible;+M SIE+6.0;+W indows+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;+M SIE+6.0;+W indows+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.a xd d=E7SSKcoyTzSew7I28vGL8RFC IEeHs43vPz xQeGQ0H101 &t=6330283 8477750000 0 80 -
66.193.142.98
Mozilla/4.0+(compatible;+M SIE+6.0;+W indows+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/MerchantLandi ng.aspx - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+M SIE+6.0;+W indows+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;+M SIE+6.0;+W indows+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/DonationConfi guration.a spx - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+M SIE+6.0;+W indows+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/do nation.css - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+M SIE+6.0;+W indows+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.g if - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+M SIE+6.0;+W indows+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/ColorPickerMa p.jpg - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+M SIE+6.0;+W indows+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;+M SIE+6.0;+W indows+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;+M SIE+6.0;+W indows+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/DonationConfi guration.a spx - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+M SIE+6.0;+W indows+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/DonationConfi guration.a spx - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+M SIE+6.0;+W indows+NT+ 5.1;+SV1;+ .NET+CLR+1 .1.4322;+.
NET+CLR+2.0.50727) 200 0 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;+M
NET+CLR+2.0.50727) 404 0 0
2007-03-27 15:44:35 W3SVC1975443634 192.168.2.8 GET /donatelinq4/merchantlogin
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:35 W3SVC1975443634 192.168.2.8 GET /DonateLINQ4/WebResource.a
66.193.142.98
Mozilla/4.0+(compatible;+M
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:51 W3SVC1975443634 192.168.2.8 POST /donatelinq4/merchantlogin
NET+CLR+2.0.50727) 302 0 0
2007-03-27 15:44:51 W3SVC1975443634 192.168.2.8 GET /donatelinq4/MerchantHome.
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:51 W3SVC1975443634 192.168.2.8 GET /DonateLINQ4/WebResource.a
80 - 66.193.142.98
Mozilla/4.0+(compatible;+M
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:51 W3SVC1975443634 192.168.2.8 GET /donatelinq4/Background.jp
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:51 W3SVC1975443634 192.168.2.8 GET /DonateLINQ4/WebResource.a
80 - 66.193.142.98
Mozilla/4.0+(compatible;+M
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:51 W3SVC1975443634 192.168.2.8 GET /DonateLINQ4/WebResource.a
80 - 66.193.142.98
Mozilla/4.0+(compatible;+M
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:51 W3SVC1975443634 192.168.2.8 GET /DonateLINQ4/WebResource.a
66.193.142.98
Mozilla/4.0+(compatible;+M
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:51 W3SVC1975443634 192.168.2.8 GET /DonateLINQ4/WebResource.a
66.193.142.98
Mozilla/4.0+(compatible;+M
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;+M
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:51 W3SVC1975443634 192.168.2.8 GET /DonateLINQ4/WebResource.a
66.193.142.98
Mozilla/4.0+(compatible;+M
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:51 W3SVC1975443634 192.168.2.8 GET /donatelinq4/MerchantLandi
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:54 W3SVC1975443634 192.168.2.8 POST /donatelinq4/MerchantHome.
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:54 W3SVC1975443634 192.168.2.8 GET /donatelinq4/DonationConfi
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:54 W3SVC1975443634 192.168.2.8 GET /donatelinq4/css/FChase/do
NET+CLR+2.0.50727) 404 0 2
2007-03-27 15:44:54 W3SVC1975443634 192.168.2.8 GET /donatelinq4/Transparent.g
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:44:54 W3SVC1975443634 192.168.2.8 GET /donatelinq4/ColorPickerMa
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;+M
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;+M
NET+CLR+2.0.50727) 403 14 5
2007-03-27 15:44:57 W3SVC1975443634 192.168.2.8 POST /donatelinq4/DonationConfi
NET+CLR+2.0.50727) 200 0 0
2007-03-27 15:45:00 W3SVC1975443634 192.168.2.8 POST /donatelinq4/DonationConfi
NET+CLR+2.0.50727) 200 0 0
ASKER
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;+M SIE+6.0;+W indows+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.
2007-03-27 15:44:54 W3SVC1975443634 192.168.2.8 GET /donatelinq4/ - 80 -
66.193.142.98
Mozilla/4.0+(compatible;+M
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.
ASKER
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;+M SIE+6.0;+W indows+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/do nation.css - 80 - 66.193.142.98 Mozilla/4.0+(compatible;+M SIE+6.0;+W indows+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
NET+CLR+2.0.50727) 404 0 0
and
2007-03-27 15:44:54 W3SVC1975443634 192.168.2.8 GET /donatelinq4/css/FChase/do
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
ASKER
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/merchanta dministrat ion/Donati onConfigur ation.aspx - 80 -66.193.142.98 HTTP/1.0Mozilla/4.0+(compa tible;+MSI E+6.0;+Win dows+NT+5. 1;+SV1;+.N ET+CLR+1.1 .4322;+.NE T+CLR+2.0. 50727) ASP.NET_SessionId=cpnk5vyx lkmlqi20hk rezg45http://dev.thecashlinqgroup.com/donatelinq4/merchantadministration/DonationConfiguration.aspx dev.thecashlinqgroup.com 500 0 0 6214 7164 78
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/merchanta
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
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
ASKER
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).
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).
ASKER
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dave Dietz