我正在努力使用这种HttpResponse.Redirect
方法。我以为它会被包括在内,System.Web
但我得到了
当前上下文中不存在名称“响应””错误。
这是整个控制器:
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web;
using System.Web.Http;
namespace MvcApplication1.Controllers
{
public class SmileyController : ApiController
{
public HttpResponseMessage Get(string id)
{
Response.Redirect("http://www.google.com");
return new HttpResponseMessage
{
Content = new StringContent("[]", new UTF8Encoding(), "application/json"),
StatusCode = HttpStatusCode.NotFound,
};
}
}
}