public void ProcessRequest(HttpContext context) { try { //Set license info for Web Editor and SDK ThermalLabelWebEditor.LicenseOwnerForEditor = "LICENSE OWNER FOR WEB EDITOR HERE"; ThermalLabelWebEditor.LicenseKeyForEditor = "LICENSE KEY FOR WEB EDITOR HERE"; ThermalLabelWebEditor.LicenseOwnerForSDK = "LICENSE OWNER FOR SDK HERE"; ThermalLabelWebEditor.LicenseKeyForSDK = "LICENSE KEY FOR SDK HERE"; //Set physical path of this website root folder ThermalLabelWebEditor.WebsiteRootPhysicalPath = context.Server.MapPath("~/"); //Pass data processing to ThermalLabelWebEditor ThermalLabelWebEditorHttpResponse httpResponse = ThermalLabelWebEditor.ProcessRequest(context.Request.HttpMethod == "POST" ? context.Request.Form : context.Request.QueryString); //set http response data context.Response.ContentType = httpResponse.ContentType; context.Response.Write(httpResponse.Content); if (string.IsNullOrEmpty(httpResponse.HeaderName) == false) { context.Response.Headers.Add(httpResponse.HeaderName, httpResponse.HeaderValue); } } catch (Exception ex) { context.Response.StatusCode = 400; context.Response.ContentType = "text/plain"; context.Response.Write(ex.Message); } }
public async Task ThermalLabelWebEditorProcessRequest(HttpContext context) { try { //Set license info for Web Editor and SDK ThermalLabelWebEditor.LicenseOwnerForEditor = "LICENSE OWNER FOR WEB EDITOR HERE"; ThermalLabelWebEditor.LicenseKeyForEditor = "LICENSE KEY FOR WEB EDITOR HERE"; ThermalLabelWebEditor.LicenseOwnerForSDK = "LICENSE OWNER FOR SDK HERE"; ThermalLabelWebEditor.LicenseKeyForSDK = "LICENSE KEY FOR SDK HERE"; //Set physical path of this website root folder ThermalLabelWebEditor.WebsiteRootPhysicalPath = this.WebRootPath; //Pass data processing to ThermalLabelWebEditor var reqData = new NameValueCollection(); foreach (var entry in context.Request.Form) { reqData.Add(entry.Key, entry.Value.ToString()); } ThermalLabelWebEditorHttpResponse httpResponse = ThermalLabelWebEditor.ProcessRequest(reqData); //set http response data context.Response.ContentType = httpResponse.ContentType; if (string.IsNullOrEmpty(httpResponse.HeaderName) == false) { context.Response.Headers.Add(httpResponse.HeaderName, httpResponse.HeaderValue); } await context.Response.WriteAsync(httpResponse.Content); } catch (Exception ex) { context.Response.StatusCode = 400; context.Response.ContentType = "text/plain"; await context.Response.WriteAsync(ex.Message); } }