Difference between revisions of "CSharp:WebAPI Soluzioni"
From Aino Wiki
(→Materiale) |
(No difference)
|
Latest revision as of 16:23, 29 November 2021
Contents
Passare un JSON restituire un PDF
Materiale
- Passare un JSON mediante POST [1]
- Effettuare una POST da C# asparticles.com
- Ricevere un JSON [2]
- Spedire un JSON ad una WebAPI [3]
- Passare un JSON ad una GET [4]
Server Info
IP del Client
Aggiungere la reference slls libreria System.ServiceModel.
using System; using System.Net.Http; using System.ServiceModel.Channels; // Necessita la reference alla libreria System.ServiceModel using System.Web; using System.Web.Http; //etc private string GetClientIp(HttpRequestMessage request = null) { request = request ?? Request; if (request.Properties.ContainsKey("MS_HttpContext")) { return ((HttpContextWrapper)request.Properties["MS_HttpContext"]).Request.UserHostAddress; } else if (request.Properties.ContainsKey(RemoteEndpointMessageProperty.Name)) { RemoteEndpointMessageProperty prop = (RemoteEndpointMessageProperty)request.Properties[RemoteEndpointMessageProperty.Name]; return prop.Address; } else if (HttpContext.Current != null) { return HttpContext.Current.Request.UserHostAddress; } else { return null; } }
Browser del Client
E' la ricerca delle info sull'UserAgent.
public string DetectClientBrowser() { string browserSignature = string.Empty; try { var userAgent = HttpContext.Current.Request.UserAgent; HttpBrowserCapabilities userBrowser = new HttpBrowserCapabilities { Capabilities = new Hashtable { { string.Empty, userAgent } } }; var factory = new BrowserCapabilitiesFactory(); factory.ConfigureBrowserCapabilities(new NameValueCollection(), userBrowser); //Set User browser Properties browserSignature = $"{userBrowser.Browser}_{userBrowser.Version}"; //m_log.Debug($"browser {browserSignature}"); } catch (Exception ex) { m_log.Error(ex.Message, ex); } return browserSignature; }
Mappa e Link
WEB API | | WebAPI Esempi | C# | Teoria
Soluzioni varie | Visual Studio
Parole chiave: