troubleshooting Question

using webrequest to get file list from website

Avatar of flynny
flynnyFlag for United Kingdom of Great Britain and Northern Ireland asked on
C#.NET ProgrammingASP.NET
7 Comments1 Solution687 ViewsLast Modified:
Hi all,

I have a dynamically generated site whereby I want to provide a list of fonts (.ttf files) that are present in a public folder on a common resource site i have setup.

for example i have which will host the generated site. I then want to use AJAX to contact (this will store all common resources for these generated sites).

now i have to following code;

WebRequest request = WebRequest.Create(fonts_path);
        WebResponse response = request.GetResponse();
        Regex regex = new Regex("<a href=\"?<url>.*\">(?<name>.*)</a>");
        List<KeyValuePair<String, String>> files = new List<KeyValuePair<String, String>>();

        using (var reader = new StreamReader(response.GetResponseStream()))
            string result = reader.ReadToEnd();

            MatchCollection matches = regex.Matches(result);
            if (matches.Count == 0)
                Console.WriteLine("parse failed.");
                return null;

            foreach (Match match in matches)
                if (!match.Success) { continue; }

                files.Add(new KeyValuePair<String, String>(match.Groups["url"].ToString(),match.Groups["name"].ToString()));

        return files;

now the url is giving a 403 forbidden error on the webrequest. I have tried adding the .htaccess file to the root directory.

Can anyone please tell me what the issue coudl be herE?
KimputerIT Manager

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros