コード例 #1
0
        public void ProcessRequest(HttpContext context)
        {
            DirectoryInfo webFolder;

            try
            {
                webFolder = new DirectoryInfo(context.Request.PhysicalApplicationPath).Parent;
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Exception while tracking 'Web' folder -{0}", ex.Message));
            }

            if (context.Request.QueryString["product"] == null && context.Request.QueryString["product"] == null)
            {
                throw new Exception("Requirred Query string [product] to handle the request.");
            }

            string path        = string.Format("{0}\\{1}", webFolder.FullName, context.Request.QueryString["product"]);
            string productname = context.Request.QueryString["product"].ToString().ToLower();

            if (!Directory.Exists(path))
            {
                context.Response.Write(string.Format("http://js.syncfusion.com/demos/", productname));
            }
            else
            {
                DirectoryInfo productFolder = new DirectoryInfo(path);

                string port         = null;
                string physicalPath = string.Format("{0}", productFolder.FullName);
                string prefixURL    = string.Empty;//.Format("mvcsamplebrowser/{0}", productFolder.Name);

                try
                {
                    string frameWorks = System.Configuration.ConfigurationManager.AppSettings["FrameWork"];
                    if (frameWorks == "4.5")
                    {
                        CassiniWebServer.StartVersion45xWebServer(physicalPath, prefixURL, out port);
                    }
                    else if (frameWorks == "4.0")
                    {
                        CassiniWebServer.StartVersion4xWebServer(physicalPath, prefixURL, out port);
                    }
                    else
                    {
                        CassiniWebServer.StartVersion3xWebServer(physicalPath, prefixURL, out port);
                    }

                    context.Response.Write(string.Format("http://localhost:{0}", port));
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format("Error: Unable to start Webserver.web.exe, Message:{0}", ex.Message));
                }
            }
        }
コード例 #2
0
        public void ProcessRequest(HttpContext context)
        {
            DirectoryInfo webFolder, installedFolder;

            try
            {
                webFolder = new DirectoryInfo(context.Request.PhysicalApplicationPath).Parent.Parent;
                while (webFolder.Name.ToLower() != "web")
                {
                    webFolder = webFolder.Parent;
                }
                installedFolder = webFolder.Parent;
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Exception while tracking 'Web' folder -{0}", ex.Message));
            }
            string productPath;

            if (context.Request.QueryString["product"] == null && context.Request.QueryString["product"] == null)
            {
                throw new Exception("Requirred Query string [product] to handle the request.");
            }
            if (context.Request.QueryString["path"] == null && context.Request.QueryString["path"] == null)
            {
                productPath = @"JavaScript\\ionic samples\\desktop\\www";
            }
            else
            {
                productPath = context.Request.QueryString["path"];
            }
            string path        = Path.Combine(installedFolder.FullName, productPath);
            string productname = context.Request.QueryString["product"].ToString().ToLower();

            if (!Directory.Exists(path))
            {
                context.Response.Write(string.Format("//asp.syncfusion.com/demos/{0}", productname));
            }
            else
            {
                DirectoryInfo productFolder = new DirectoryInfo(path);

                string port         = null;
                string physicalPath = string.Format("{0}", productFolder.FullName);
                string prefixURL    = string.Empty;

                try
                {
                    string frameWorks = System.Configuration.ConfigurationManager.AppSettings["FrameWork"];
                    if (frameWorks == "4.5" || frameWorks == "4.5.1" || frameWorks == "4.0" || frameWorks == "4.6")
                    {
                        CassiniWebServer.StartVersion45xWebServer(physicalPath, prefixURL, out port);
                    }
                    else
                    {
                        CassiniWebServer.StartVersion3xWebServer(physicalPath, prefixURL, out port);
                    }

                    context.Response.Write(string.Format("http://localhost:{0}", port));
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format("Error: Unable to start Webserver.web.exe, Message:{0}", ex.Message));
                }
            }
        }