Use the MacBook to develop desktop apps, using Alamofire link. Net Core webapi Considerations!

Source: Internet
Author: User
Tags webhost pfx file macbook

------------HTTPS mode-----------------------

Because SWIFT9 after the access interface can only use HTTPS, so in the background to add a PFX file (how to generate, self-Baidu bar)
1. Place the PFX under the project root directory.
2. Change the program's start-up to

Webhost.createdefaultbuilder (args)//. Usekestrel (option = {//option. Listen (System.Net.IPAddress.Any, 5001, (lop) + = {//lop. UseHttps ("Server.pfx", "111");//})//. Useurls ("https://*:5001")//. Usecontentroot (Directory.GetCurrentDirectory ())//. Useiisintegration ()//. Usestartup<startup> ()//. Build (); 3. Background modification is complete. 4.Swift is used in the Alamofire call, " ATS failed System Trust ", by Baidu, Apple's access to the HTTP control more and more stringent, here must be the CA certificate, in the online application certificate and domain name, because it is a local development project, there is no relevant information, so give up this way. -----------http mode------------------------ then on the internet to find a way to local HTTP 1. Add the Red Font section to the Info.plist

<key>NSPrincipalClass</key>

<string>NSApplication</string>

<key>NSAppTransportSecurity</key>

<dict>

<key>NSAllowsArbitraryLoads</key>

<true/>

</dict>

</dict>

</plist>

2. Change the. Net Core code back (if you install the method above)

Webhost.createdefaultbuilder (args). Usestartup<startup> (). Build (); 3. Using code testing in Swift

Alamofire.request ("Http://localhost:5000/api/******/gettables"). Responsejson {response in

Print (Response.request)//original URL request

Print (Response.response)//HTTP URL response

Print (Response.data)//data returned by the server

Print (Response.result)//Response serialization results, in this closure, the JSON data is stored

If let JSON = response.result.value {

Print ("JSON: \ (JSON)")

}

}

Use the MacBook to develop desktop apps, using Alamofire link. Net Core webapi Considerations!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.