Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Request.PathInfo not work

$
0
0

Request.PathInfo show "The resource cannot be found" error when click on second link

my code shown below :

article.aspx
<form id="form1" runat="server">
    <div>
     <ul>
            <li><a href="article.aspx/book">Books</a></li>
            <li><a href="article.aspx/story">DVDs</a></li>
            <li><a href="article.aspx/songs">CDs</a></li>
        </ul>
        
        Request.PathInfo value:
        <asp:Label ID="Label1" runat="server" ></asp:Label>
    </div>
    </form>

.cs page : article.aspx.cs

 protected void Page_Load(object sender, EventArgs e)
        {
            string url = GetCategory();
            Label1.Text = url;


        }
        public string GetCategory()
        {

            if ((Request.PathInfo.Length == 0))
            {
                return "";
            }
            else
            {
                return Request.PathInfo.Substring(1);
            }

        }

my problem is Request.PathInfo work only first time when click a any one  link.. the second time click this show error "The resource cannot be found".

please help me ... thanks advance ...


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>