Namespace is in class but not in aspx

I'm having problems with the namespace System.Net.Http.

I want to use, for example. HttpClient, from the namespace System.Net.Http. When I use using System.Net.Http;in a C # class, I can use HttpClient just fine, but when I try to import a namespace in an aspx file, for example: %@ Import Namespace="System.Net.Http" %>it will not register HttpClient:

Could not find the name of the type or namespace "HttpClient" (are you missing the using directive or assembly references?)

I already installed it as this and added it to my links by doing this .

How to use, for example. HttpClient in my .aspx file, how do I use it in a C # class?

UPDATE

This is not a duplicate. Why should I include a namespace on every aspx page? because I am not asking how should I include the namespace in each class.

+4
source share
1 answer

First, it’s worth noting that you probably shouldn't do this. You should probably prepare the data needed in the Page_Load event and just display it on the WebForms page. If you still want to do this, I'm sure that what happens is that you have a dependent assembly other than System.Web.HttpClient. Take a look at your CodeBehind page and make sure all importers are on the aspx page for each use in CodeBehind. In other words:

System.Web.HttpClient , .

+2

All Articles