vishal sharma

vishal sharma

  • NA
  • 31
  • 1.7k

URL Routing in asp.net 4.5

Mar 26 2018 7:53 AM
get this error when i open a url
 

Cannot use a leading .. to exit above the top directory.

my code in global.asax is :-
 
void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("Home", "Home", "~/index.aspx");
routes.MapPageRoute("About", "About", "~/About.aspx");
routes.MapPageRoute("Client", "Client", "~/Client.aspx");
routes.MapPageRoute("Career", "Career", "~/Career.aspx");
routes.MapPageRoute("Contact", "Contact", "~/Contact.aspx");
 
routes.MapPageRoute("Product", "Product/{SID}/{SubCategory}", "~/Product.aspx"); --> on this i get this error.
 
}
 
link on master page :-
 
<div class="collapse navbar-collapse" id="myNavbar">
<asp:Repeater ID="rptmain" runat="server" OnItemDataBound="rptmain_ItemDataBound">
<ItemTemplate>
<ul class="nav navbar-nav">
<li class="dropdown"><a href="#"><%#Eval("Main_Category") %></a>
<div class="dropdown-content">
<asp:Repeater ID="rptsub" runat="server">
<ItemTemplate>
<%--<a href="../Product.aspx?SID=<%#Eval("SID") %>&SubCategory=<%#Eval("Sub_Category") %>"><%#Eval("Sub_Category") %></a>--%>
<a href='Product/<%#Eval("SID").ToString()%>/<%#Eval("Sub_Category").ToString()%>'><%#Eval("Sub_Category")%></a>
</ItemTemplate>
</asp:Repeater>
</div>
</li>
</ul>
</ItemTemplate>
 
</asp:Repeater>
</div>
 
 Product page code is :-
 
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetProducts();
}
}
public void GetProducts()
{
DataSet Nteturn;
Nteturn = SqlHelper.ExecuteDataset(SqlHelper.GetConnection(), CommandType.StoredProcedure, "SP_Product"
, SqlHelper.CreatePerameter("@Action", SqlDbType.NVarChar, "Show_Product", ParameterDirection.Input, 100000, false)
, SqlHelper.CreatePerameter("@SID", SqlDbType.NVarChar, Request.QueryString["SID"], ParameterDirection.Input, 100000, false)
);
if (Nteturn.Tables[0].Rows.Count > 0)
{
rptproduct.DataSource = Nteturn.Tables[0];
rptproduct.DataBind();
lblcat.Text = Nteturn.Tables[0].Rows[0]["Main_Category"].ToString();
lblsubcat.Text = Nteturn.Tables[0].Rows[0]["Sub_Category"].ToString();
}
}
 
Please help me to solve this problem 
 
 

Answers (2)