public void Publish(WebServiceHandler h) { var publish = h.Context.Request.Path.SkipUntilOrEmpty("/publish/"); var p = new Publish(); if (p.ContainsKey(publish)) { var f = p[publish]; var bytes = File.ReadAllBytes(f); h.Context.Response.OutputStream.Write(bytes, 0, bytes.Length); h.CompleteRequest(); } }
public static void DownloadSDK(WebServiceHandler h) { const string _download = "/download/"; const string a = @"assets/PromotionWebApplicationAssets"; var path = h.Context.Request.Path; if (path == "/download") { //h.Context.Response.Redirect("/download/jsc.configuration.application"); // F# redist h.Context.Response.Redirect("/download/jsc-web-installer.exe"); h.CompleteRequest(); return; } if (path == "/download/jsc-web-installer.exe") { // http://msdn.microsoft.com/en-us/library/h4k032e1.aspx // is chrome happier if we rename it? path = "/download/setup.exe"; } if (path == "/download/") { var href = "http://www.jsc-solutions.net/download/jsc-web-installer.exe"; var html = @" <meta http-equiv='Refresh' target='_top' content='1;url=" + href + @"' /> <center> <br /> <br /> <br /> <a href='" + href + @"'>Thank you for downloading JSC!</a> <br /> <br /> <br /> <br /> <br /> <div><i>Note that recent versions of <b>Google Chrome</b> may need additional time to verify.</i></div> </center>"; h.Context.Response.ContentType = "text/html"; var bytes = Encoding.UTF8.GetBytes(html); h.Context.Response.OutputStream.Write(bytes, 0, bytes.Length); h.CompleteRequest(); return; } #if !DEBUG // we will compare the win32 relative paths here... var publish = path.SkipUntilOrEmpty("/download/").Replace("/", @"\"); var p = new Publish(); if (p.ContainsKey(publish)) { var f = p[publish]; var ext = "." + f.SkipUntilLastOrEmpty(".").ToLower(); // http://en.wikipedia.org/wiki/Mime_type // http://msdn.microsoft.com/en-us/library/ms228998.aspx var ContentType = "application/octet-stream"; if (ext == ".application") { ContentType = "application/x-ms-application"; } else if (ext == ".manifest") { ContentType = "application/x-ms-manifest"; } else if (ext == ".htm") { ContentType = "text/html"; } h.Context.Response.ContentType = ContentType; //Console.WriteLine("length: " + data.Length + " " + ContentType + " " + f); DownloadSDKFile(h, f); } #endif return; }