Exemple #1
0
        public string Error404(string sTargetURL)
        {
            lCMS             cCMS = new lCMS();
            List <eArticulo> lArt = cCMS.ArticuloPlantilla_listarWeb(94, 10, 1, 0);

            if (lArt.Count > 0)
            {
                sTargetURL = "Content/Index.aspx?aID=" + lArt[0].IdArticulo.ToString();
                ClientScriptHelper.Redirect301(this.Context, ClientScriptHelper.getEnlace_Articulo(lArt[0]));
            }
            return(sTargetURL);
        }
Exemple #2
0
        private void CheckURLMapping()
        {
            lCMS   cCMS = new lCMS();
            string root = ClientScriptHelper.getURLRoot();

            // If the requested file exists
            HttpContext current = HttpContext.Current;

            current.Trace.Warn("ApplicationInstance", Context.ApplicationInstance.GetType().FullName);
            current.Trace.Warn("Request.Url", current.Request.Path.ToString());
            current.Trace.Warn("Request.RequestType", current.Request.RequestType);

            if (current.Request.RequestType == "" || !current.Request.PhysicalPath.EndsWith("\\404.aspx") && File.Exists(current.Request.PhysicalPath))
            {
                // Do nothing here, just serve the file
                current.Trace.Warn("File.Exists", "No hace nada");
            }
            // If the file does not exist then
            else
            {
                // Get the URL requested by the user
                string sRequestUrl = current.Request.Url.ToString().ToLower();
                if (sRequestUrl.Contains(".axd") || sRequestUrl.EndsWith(".gif") || sRequestUrl.EndsWith(".jpg") || sRequestUrl.EndsWith(".swf") || sRequestUrl.EndsWith(".bmp") || sRequestUrl.EndsWith(".ico") || sRequestUrl.EndsWith(".js"))
                {
                    return;
                }

                string[] aRequest   = current.Request.Url.ToString().Split(';');
                string   urlRequest = "";

                string sParameters   = "";
                string sRequestedURL = "";

                if (aRequest.Length > 1)
                {
                    urlRequest = aRequest[1].Substring(aRequest[1].IndexOf('/', 10));
                }
                else
                {
                    //sRequestedURL = Request.Path.Substring(1);
                    sRequestedURL = Request.Path;
                    sParameters   = current.Request.Url.Query;
                    if (sParameters != "")
                    {
                        sParameters = sParameters.Substring(1);
                    }
                }

                //if (sRequestedURL.EndsWith("/")) sRequestedURL = sRequestedURL.Substring(0, sRequestedURL.Length - 1);
                if (sRequestedURL.StartsWith(root))
                {
                    sRequestedURL = sRequestedURL.Substring(root.Length);
                }
                //sRequestedURL = urlRequest.Substring(1);

                // You can retrieve the ID of the content from database that is
                // relevant to this requested URL (as per your business logic)

                current.Trace.Warn("sRequestedURL", sRequestedURL);
                current.Trace.Warn("sParameters", sParameters);
                string sTargetURL = "Content/Index.aspx"; //Change to Page Not Found: ERROR 404


                string sURLnew = URLRedirect.Get301(sRequestedURL);
                if (sURLnew != sRequestedURL)
                {
                    ClientScriptHelper.Redirect301(this.Context, root + sURLnew);
                    sRequestedURL = sURLnew;
                }
                string Registro = (Request["registro"] != null) ? (Request["registro"]).ToString() : "";
                if (Registro == "true")
                {
                    sRequestedURL = "registro";
                }
                switch (sRequestedURL)
                {
                case "": sTargetURL = "Content/Index.aspx"; break;

                //case "productos/producto_item": sTargetURL = "Content/ProductoItem.aspx?idproducto=" + IdProducto; break;
                case "producto_wishlist": sTargetURL = "Content/ProductoWishlist.aspx"; break;

                case "producto_compras": sTargetURL = "Content/ProductoCompras.aspx"; break;

                case "registro": sTargetURL = "Content/Registro.aspx"; break;

                case "home": sTargetURL = "Content/Index.aspx"; break;

                case "admin": sTargetURL = "Admin/Index/login.aspx"; break;

                case "despacho": sTargetURL = "Content/Despacho.aspx"; break;

                case "verificar": sTargetURL = "Content/Verificar.aspx"; break;

                case "cuenta": sTargetURL = "Content/Cuenta.aspx"; break;

                case "cuenta_detalle": sTargetURL = "Content/CuentaDetalle.aspx"; break;

                case "direccion_despacho": sTargetURL = "Content/DireccionDespacho.aspx"; break;

                case "historial_pedidos": sTargetURL = "Content/Historial_Pedidos.aspx"; break;

                case "confirmacion_visanet": sTargetURL = "Content/Gracias-compra.aspx"; break;

                case "direccion": sTargetURL = "Content/Direccion.aspx"; break;

                case "direccionfancybox": sTargetURL = "Content/DireccionFancybox.aspx"; break;

                case "restablecer-contrasena": sTargetURL = "Content/PagRestablecer-Contrasena.aspx"; break;

                case "libro-reclamaciones": sTargetURL = "Content/Libro_Reclamaciones.aspx"; break;

                case "libro-reclamaciones-detalle": sTargetURL = "Content/Libro_Reclamaciones_Detalle.aspx"; break;

                case "libro-reclamaciones-gracias": sTargetURL = "Content/Libro_Reclamaciones_Gracias.aspx"; break;

                case "job": sTargetURL = "Content/job.aspx"; break;

                default:
                    if (sRequestedURL.Contains("/"))
                    {
                        eArticulo oArticulo = new eArticulo();

                        int IDPagina = cCMS.Articulo_item(sRequestedURL);
                        if (IDPagina > 0)
                        {
                            sTargetURL = "Content/Index.aspx?aID=" + IDPagina.ToString();
                        }
                        else
                        {
                            sTargetURL = Error404(sTargetURL);
                        }
                    }
                    else
                    {
                        eMenuWebDetalle eMenuWebDetalle = new eMenuWebDetalle();

                        int IDSeccion = cCMS.MenuWebDetalle_item(sRequestedURL);
                        if (IDSeccion > 0)
                        {
                            sTargetURL = "Content/Index.aspx?mwID=" + IDSeccion.ToString();
                        }
                        else
                        {
                            sTargetURL = Error404(sTargetURL);
                        }
                    }
                    break;
                }

                if (sParameters != "")
                {
                    sTargetURL += (sTargetURL.Contains("?") ? "&" : "?") + sParameters;
                }

                current.Trace.Warn("sTargetURL", sTargetURL);

                // Owing to RewritePath, the user will see requested URL in the address bar
                // The second argument should be false, to keep your references
                // to images, css files
                Context.RewritePath(root + sTargetURL, false);
            }
        }