【问题标题】:The remote server returned an error: (410) Gone in C#远程服务器返回错误:(410) Gone in C#
【发布时间】:2017-06-29 15:26:18
【问题描述】:

我有一个由第三方应用程序使用的 Web API2 应用程序。当应用程序到达我的端点时,我的应用程序发送 oAuth 凭据进行身份验证并从第三方应用程序获取结果。

最近一些事务失败,当我添加一些日志时,我看到错误:远程服务器返回错误:(410) Gone 发生在所有失败的事务中。不幸的是,当我调用我的应用程序时,我无法重现此问题。以下是我正在使用的代码。导致此错误的问题可能是什么?

 public async Task<customerModel>  SendSigned(string url)
{
    customerModel customermodel = null;
    try
    {
        OAuthBase oauthBase = new OAuthBase();

        string oAuthKey = ConfigurationManager.AppSettings["oAuthKey"];
        string oAuthSecret = ConfigurationManager.AppSettings["oAuthSecret"];
        string timestamp = oauthBase.GenerateTimeStamp();
        string nonce = oauthBase.GenerateNonce();
        string normalizedUrl;
        string normalizedRequestParameters;
        string sig = HttpUtility.UrlEncode(oauthBase.GenerateSignature(
            new Uri(url), oAuthKey, oAuthSecret, string.Empty, string.Empty,
            "GET", timestamp, nonce, out normalizedUrl, out normalizedRequestParameters));
        string requestUrl = String.Format("{0}?{1}&oauth_signature={2}", normalizedUrl, normalizedRequestParameters, sig);

        HttpWebRequest request = null;
        request = (HttpWebRequest)HttpWebRequest.Create(requestUrl);
        using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
        {
           myXMLDocument = new XmlDocument();
           customermodel = GetCustomerInformation(response);
        }

        return await Task.Run(() => customermodel);
    }
    catch (Exception ex)
    {
       _logger.Error("Error in SendSigned method", ex.InnerException);
        return customermodel;
    }
}

【问题讨论】:

    标签: c# asp.net asp.net-web-api2 http-status-code-410


    【解决方案1】:

    410 的解释是目标资源在源服务器上不再可用,并且这种情况很可能是永久性的 this链接(类似于404)

    我建议您考虑一下您最近对自己所做的更改

    1. API 签名
    2. 文件夹重组/资产/资源重组
    3. 路由更改
    4. 资源重命名

    【讨论】:

    • 此问题是间歇性发生的,并非一直发生。所以看起来文件夹结构/API签名是一样的
    猜你喜欢
    • 1970-01-01
    • 2019-10-10
    • 1970-01-01
    • 1970-01-01
    • 2013-03-24
    • 2014-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多