Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

C# C# Streams and Data Processing Streaming Data on the Net WebClient

Problem with "DownloadData" method of WebClient.

Can't figure out why my code's not passing muster with the C# Streams and Data Processing quiz. Complete code should be attached - let me know if it's not showing up for some reason. The relevant lines are:

 using (var webClient = new WebClient())
             {
                 byte[] treehouseBytes = webClient.DownloadData("https://www.teamtreehouse.com/");
             }

This code gets the error:

  Bummer: Did you pass the url "https://www.teamtreehouse.com" into the 'DownloadData' method?

Task 2 of "WebClient" quiz: https://teamtreehouse.com/library/c-streams-and-data-processing/streaming-data-on-the-net/webclient

Program.cs
using System;
using System.IO;
using System.Net;

namespace Treehouse.CodeChallenges
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(GetTreehouseHome());
        }

        public static string GetTreehouseHome()
        {
            string treehouse = "";

            using(var webClient = new WebClient())
            {
                   byte[] treehouseBytes = webClient.DownloadData("https://www.teamtreehouse.com/");
            }

            return treehouse;
        }
    }
}

2 Answers

Remove the forward slash at the end so it is just "https://www.teamtreehouse.com"

Thank you! That was it.