Solved

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

Posted on 2007-03-23
11
716 Views
Last Modified: 2008-03-03
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());
}
0
Comment
Question by:jdhibberd
  • 6
  • 3
11 Comments
 
LVL 34

Expert Comment

by:Dave_Dietz
ID: 18788734
What shows up in the w3svc log for the requests that fail?

Dave Dietz
0
 

Author Comment

by:jdhibberd
ID: 18802106
#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
0
 

Author Comment

by:jdhibberd
ID: 18802376
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.
0
 

Author Comment

by:jdhibberd
ID: 18803594
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).  
0
 
LVL 34

Expert Comment

by:Dave_Dietz
ID: 18804748
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
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:jdhibberd
ID: 18805534
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
0
 
LVL 34

Expert Comment

by:Dave_Dietz
ID: 18805675
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
0
 

Author Comment

by:jdhibberd
ID: 18810557
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).
0
 

Author Comment

by:jdhibberd
ID: 18819691
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.  
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 19229758
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Today I came across an interesting issue that had me pulling my hair out.  I was troubleshooting a new internal web site which uses integrated security instead of anonymous.  When browsing the site from my laptop, I was able to access it with no iss…
Lync server 2013 Backup Service Error ID 4049 – After File Share Migration
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now