------------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!