Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm trying to make a friendly url following the instructions on this page[^].
in order to change `www.samplepage.com/Default.aspx?Category=Desserts&Page=4` into `www.samplepage.com/Default.aspx/Desserts/Page4`. It works however, every time I enter the friendly URL, it enters the page twice. I couldn't say it is a postback, since it enters on the validation `if(!IsPostBack)` and it happens on each page i tried, complex pages and text only pages.

How can I prevent this double page entry?

ASPX code

C#
    <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="ResultPool.aspx.cs" Inherits="Drawit.ResultPool" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <link href="Content/Site.css" rel="stylesheet" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <ul>
        <li class="labelForm"><asp:Label ID="lblResult" runat="server" Text=""></asp:Label></li>
        <li class="labelForm"><asp:Label ID="lblOriginal" runat="server" Text=""></asp:Label></li>

        <li class="labelForm"><asp:Button ID="btnHome" runat="server" Text="Button" OnClick="btnHome_Click" /></li>
    </ul>
</asp:Content>


.CS code

C#
public partial class ResultPool : System.Web.UI.Page
{


    protected void Page_Load(object sender, EventArgs e)
    {
        string Mensaje = "El proceso de ";
        string RutaArchivo = "~/Images/Results/";
        if (!IsPostBack)
        {
            try
            {
                string stats;
                if (Request.PathInfo.Length > 0)
                    stats = Request.PathInfo.Substring(1);
                else
                    stats = "Error";

                string[] result = stats.Split('/');
                stats = result[0];

                switch (stats)
                {
                    case "OK":
                        {
                            Mensaje += result[1] + " ha finalizado con exito!";
                            break;
                        }
                    case "NO":
                        {
                            Mensaje += result[1] + " ha tenido un error y no pudo finalizar!";
                            break;
                        }
                    case "Error":
                        {
                            Mensaje = "Ha ocurrido un error. Por favor intente mas tarde.";
                            break;
                        }
                    default:
                        {
                            Mensaje = "Ha ocurrido un error. Por favor intente mas tarde.";
                            break;
                        }
                }
                lblResult.Text = Mensaje;
            }
            catch (Exception)
            {
                lblResult.Text = "There was an error!";
            }

        }
    }
Posted
Updated 11-Mar-13 10:53am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900