void Application_BeginRequest(Object sender, EventArgs e)
        {
            ReportSample sampleData = new ReportSample();;
            int          pathLen;
            string       path                 = HttpContext.Current.Request.Path;
            string       basePath             = HttpContext.Current.Request.ApplicationPath == "/" ? HttpContext.Current.Request.ApplicationPath : (HttpContext.Current.Request.ApplicationPath + "/");
            bool         isinitialRouting     = basePath == path || (basePath == path + "/");
            bool         isRDLCReportDesigner = path.Contains("/ReportDesigner/RDLC") && !path.Contains("/api/");
            bool         isReportDesigner     = path.Contains("/ReportDesigner") && !path.Contains("/api/");

            string[] urlPaths = new Regex(basePath).Replace(path, "", 1).Split('/');
            pathLen = urlPaths.Length;
            if (pathLen > 0 && !isinitialRouting && !isReportDesigner && !path.Contains("/api/"))
            {
                string reportBasePath = urlPaths[0];
                string reportRouterPath;
                if (path.Contains("/Preview"))
                {
                    reportRouterPath = urlPaths[1] != "Preview" ? urlPaths[1] : "";
                }
                else
                {
                    reportRouterPath = pathLen > 1 ? urlPaths[1] : "";
                }
                sampleData = getSampleData(reportBasePath, reportRouterPath, sampleData);
            }
            HttpContext.Current.Items["isPreview"] = path.Contains("/Preview") || path.Contains("/ReportDesigner");
            bool sourceTab = HttpContext.Current.Request.QueryString.ToString().Contains("sourceTab=true");

            if (sourceTab)
            {
                string res = System.IO.File.ReadAllText(HttpContext.Current.Request.PhysicalPath);
                Response.Clear();
                Response.ClearHeaders();
                Response.AddHeader("Content-Type", "text/plain");
                Response.Write(res);
                Response.Flush();
                Response.End();
            }
            else if (isinitialRouting)
            {
                HttpContext.Current.Response.RedirectPermanent(basePath + "ReportViewer/ProductLineSales");
            }
            else if (isRDLCReportDesigner)
            {
                HttpContext.Current.Items["designerType"] = "RDLC";
                Context.RewritePath(path.Replace(path, "~/Views/RDLC/Index.aspx"));
            }
            else if (isReportDesigner)
            {
                HttpContext.Current.Items["designerType"] = "RDL";
                Context.RewritePath(path.Replace(path, "~/Views/ReportDesigner/Index.aspx"));
            }
            else if (sampleData.isReportSample)
            {
                string reportRouterPath = sampleData.routerPath == "" ? sampleData.basePath : sampleData.routerPath;
                HttpContext.Current.Items["sampleName"] = reportRouterPath;
                Context.RewritePath(path.Replace(path, "~/Views/" + reportRouterPath + "/Index.aspx"));
            }
        }
        ReportSample getSampleData(string reportBasePath, string reportRouterPath, ReportSample sampleData)
        {
            dynamic samples = SampleData.getSampleData().samples;

            foreach (dynamic sample in samples)
            {
                if (sample.routerPath == reportRouterPath && sample.basePath == reportBasePath)
                {
                    sampleData.isReportSample = true;
                    sampleData.routerPath     = reportRouterPath;
                    sampleData.basePath       = reportBasePath;
                }
            }
            return(sampleData);
        }