我正在开发一个WEB API 2项目,我正在尝试在我的REST服务器上设置一个基本的身份验证系统。 我在启动应用程序时遇到错误问题而我找不到此错误的来源。
课程代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using System.Web.Http;
namespace CalypsoWebApplication.App_Code
{
public class ResultWithChallenge : IHttpActionResult
{
private readonly System.Web.Http.IHttpActionResult next;
public ResultWithChallenge(IHttpActionResult next)
{
this.next = next;
}
public async Task<HttpResponseMessage> ExecuteAsync(
CancellationToken cancellationToken)
{
var res = await next.ExecuteAsync(cancellationToken);
if (res.StatusCode == HttpStatusCode.Unauthorized)
{
res.Headers.WwwAuthenticate.Add(
new AuthenticationHeaderValue("Basic", null));
}
return res;
}
}
}
Erreur au lancement:
Message d'erreur du compilateur:CS0246:Le type ou le nom d'espace de noms'HttpResponseMessage'est introuvable(使用ouuneréférenced'assestest-elle manquante进行指令?)
英文翻译:无法找到类型或命名空间'HttpResponseMessage',是使用指令还是汇编引用缺失?
Erreur来源: Ligne 22:} Ligne 23: Ligne 24:公共异步任务ExecuteAsync( Ligne 25:取消语音取消语言) Ligne 26:{ Fichier来源:e:\ Users \ mehin \ Documents \ Visual Studio 2013 \ Projects \ Calypso \ CalypsoWebApplication \ App_Code \ ResultWithChallenge.cs Ligne:24在https://msdn.microsoft.com/fr-fr/library/w7xf6dxs.aspx查看此错误的可能来源时,我仍然不明白为什么会发生这种情况。
我不知道还能添加什么,请不要犹豫,询问更多细节。