【问题标题】:.NET Framework 3.5 and System.Net.Http not found.NET Framework 3.5 和 System.Net.Http 未找到
【发布时间】:2017-07-12 08:57:55
【问题描述】:

我有一个包含一些 asmx 文件的框架 3.5 项目。 当我在 asmx 方法中出现异常时,我想返回一个错误响应:

try{
...
...
catch (Exception ex)
{
    var errorResponse = new HttpResponseMessage(HttpStatusCode.BadRequest)
    {
        Content = new StringContent(ex.Message), ReasonPhrase = ex.Message
    };
    return errorResponse;
}

但是我不能使用 HttpResponseMessage 类,因为我不能引用 Sytem.Net.Http 命名空间!

谁能帮帮我? 谢谢

【问题讨论】:

    标签: system.net


    【解决方案1】:

    System.Net.Http是4.0引入的,没有3.5版本。无论如何,这不是 asmx 的正确返回类型,你应该去看看 System.Web。

    【讨论】:

    • 谢谢 Tratcher。我必须使用。 3.5.您建议返回什么错误响应?
    猜你喜欢
    • 1970-01-01
    • 2019-05-10
    • 2020-01-24
    • 2010-11-01
    • 2011-06-28
    • 1970-01-01
    • 1970-01-01
    • 2020-04-16
    • 2015-10-25
    相关资源
    最近更新 更多