GhostBin异常:远程服务器返回错误:(406)Not Acceptable

时间:2016-12-30 08:26:47

标签: c# webclient

Aight,在我被重定向到一些不回答此问题的帖子之前。我想声明我正在创建一个程序AUTO UPDATER。它是如何工作的,如果它看到1.0.0.0然后很好,1.0.0.1然后更新。

所以我去了Ghostbin,这是一个允许你在那里更改文本的网站,我把它链接到我的代码。事情是,它给了我这个错误。我不知道如何解决它。

  

异常:远程服务器返回错误:(406)Not Acceptable

这是我的代码。

private void button1_Click(object sender, EventArgs e)
{
    if (!new WebClient().DownloadString("https://ghostbin.com/paste/odmbf")
                        .Contains("1.0.0.0"))
    {
        MessageBox.Show("You are running the latest version!", "No Update",
                        MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
    else
    {
        if (MessageBox.Show("New Update! Would you like to update?", "Yay!", 
            MessageBoxButtons.YesNo, MessageBoxIcon.Information) == 
            System.Windows.Forms.DialogResult.Yes)
        {
            Process.Start("...");
        }
    }
}

2 个答案:

答案 0 :(得分:2)

Ghostbin似乎不接受WebClient。

假冒它使用

显示为浏览器
wc.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36");

答案 1 :(得分:0)

找到答案。请改用pastebin。他们有一个编辑选项,您可以在其中编辑原始文件!