GhostBin Exception: The remote server returned an error: (406) Not Acceptable

安稳与你 提交于 2019-12-11 04:27:50

问题


Aight, before I get redirected to some post that doesn't answer this. I would like to state that I am creating a program AUTO UPDATER. And how it works is that if it sees 1.0.0.0 then fine, 1.0.0.1 then update.

So I went to Ghostbin, a site that allows you to change text on there and I linked it up to my code. Thing is, it gave me this error. I don't know how to fix it.

Exception: The remote server returned an error: (406) Not Acceptable

Here is my code.

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("...");
        }
    }
}

回答1:


Ghostbin doesn't seem to accept the WebClient.

Fake it to appear as a browser using

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");



回答2:


Found the answer. Use pastebin instead. they have an edit option where you can edit a raw file!



来源:https://stackoverflow.com/questions/41393035/ghostbin-exception-the-remote-server-returned-an-error-406-not-acceptable

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!