问题
So I'm writing a program in C# Visual Studio 2013. At the top of my code, among my usings, I have:
using System.Web;
But when I try to use the line:
HttpResponse httpResp = (HttpResponse)response;
then Intellisense says there is no HttpResponse class, in spite of the fact that HttpResponse is part of the System.Web namespace according to this page: https://msdn.microsoft.com/en-us/library/system.web.httpresponse(v=vs.110).aspx
Furthermore it doesn't give me any options as to what else I could import that would make that class available. What am I doing wrong here? Is HttpResponse deprecated? If it is, is there a different way to get the status code of an http response.
回答1:
There are multiple dll's that have the namespace System.Web, such as System.Web.Entity. You need to Add Reference to the base System.Web dll and it should work.
回答2:
Check your project references, you're probably missing Syetem.web.
来源:https://stackoverflow.com/questions/36091629/c-system-web-httpresponse-class-not-available-in-intellisense