WebClient problem with URL which ends with a period

后端 未结 5 1816
无人及你
无人及你 2021-01-21 13:48

I\'m running the following code;

using (WebClient wc = new WebClient())
{
    string page = wc.DownloadString(URL);
    ...
}

To access the URL

5条回答
  •  暖寄归人
    2021-01-21 14:24

    Try adding a slash to the end, after the period. Your normal web browser will do that for you, and the WebClient class isn't that smart.

    http://www.shareprice.co.uk/TW./
    

    This worked for me as well when I typed it into the browser.

    Edit - added

    The following all also worked in the browser

    http://www.shareprice.co.uk/TW
    

    and

    http://www.shareprice.co.uk/TW/

    so it looks like you should be able to just check to see if the last character is a period, and remove it.

提交回复
热议问题