0

I am in the process of changing my Windows 8.1 store application to use TLS 1.2. This was required by the client who recently moved all Web APIs to HTTPS and forced the entire traffic network to use TLS 1.2. My store app started having communication issues with the Web API and the reason is that it is not forcing its calls to the Web API to use TLS 1.2. After some research, I saw that the System.Net.Http classes I used for the communication (HttpClient and HttpClientHandler) are not going to help me. I need to use similar API from Windows.Web.Http. From my readings, I also saw that I need to retarget all my projects in the solution to .NET Framework 4.6 and Windows Universal 10.0. That triggered a lot of changes (for some projects I had to uninstall all NuGet Packages before I changed the targets). Anyway, I am finally at the point where I am ready to start using the HttpClient class from Windows.Web.Http namespace. The problem is that I can't find which NuGet package I need to install to bring this namespace into my project. Simply entering "using Windows.Web.Http" is not enough as the namespace is not known.

Any ideas on how to add that API to my project?

TIA, Ed

Edit 1: For Sunteen, to see how my project has its targets configured:

enter image description here

When I tried to add this line "using Windows.Web.Http", Windows appears with the red squiggly line underneath.

Edit 2: Here is how the Library tab looks like in the Project's settings: enter image description here

Edit 3: My Windows Store 8.1 app uses a Portable Class Library that incorporates a Web API Client which is making all RESTful calls:

enter image description here

Is the type of the library (Portable) the wrong type?

Edit4 (for Sunteen): Hi Sunteen, The Tablet.WebApi.Client was just a Class Library project that encapsulated all the functionality needed to call a RESTful Web API. The application that makes use of that library is a Windows 8.1 Store application. I have since changed all Class Libraries to be Windows 8.1 Class Library, as opposed to Portable Class Library as per my original screenshot. Here is the entire structure of the solution:

enter image description here

Since the Tablet.WebApi.Client library is the one that contains the functionality used to call the RESTful Web API, it is here where I needed to replace the System.Net.Http.HttpClient class with the Windows.Web.Http version.

I am still confused about the type of project my XXXXXTabletApp needs to be. I can retarget all my class libraries to use .NET Framework 4.6 and Windows Universal 10.0 but I cannot do the same with the XXXXXTabletApp project since that one is a clear Windows 8.1 Store application. I guess the solution is to create a new UWL application and that will be able to link with all my retargeted class libraries. Is this approach correct?

Eddie
  • 271
  • 4
  • 18

2 Answers2

1

The problem is that I can't find which NuGet package I need to install to bring this namespace into my project.

You don't need any Nuget packages to use Windows.Web.Http namespace. Check one of the APIs, for example HttpClient class, you will find this class just require your UWP app is target build 10240 or higher. In another word, if your app is UWP app, you could add using Windows.Web.Http successfully.
If you already retarget the app to windows universal 10 correctly, it should work. More details please reference Move from Windows Runtime 8.x to UWP.

If you still have issues to add Windows.Web.Http, there may be somethings wrong when you retargeting. In that case, please share more details.

Update:

It seems like you didn't make your issue clearly. According to your screenshot, the template of the project you are using should be a Class Library (Legacy Portable), not a windows 8.1 app. For a windows 8.1 app project, it cannot be re-target as the picture showed. In that case, Windows.Web.Http doesn't support this class library. You can only use the namespace in a UWP app, please check Create your first app.

Additionally. as the Visual Studio 2017 mentioned, Class Library (Legacy Portable) is legacy you should not use it and the new way is .NET Standard and .NET Core.

Sunteen Wu
  • 10,509
  • 1
  • 10
  • 21
0

The final solution that I adopted was to rewrite the entire application as an Universal Windows Platform app. All the class libraries were recreated as UWP Class library. The logging feature had to be rewritten as the PortiLog approach was not available in UWP. With this in place, I could use HttpClient from the Windows.Web.Http namespace.

Eddie
  • 271
  • 4
  • 18