且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在web.sitemap中使用不同的URL调用两次相同的页面

更新时间:2023-01-04 15:59:23

在站点地图中使用QueryString也是个坏主意。两个认可上一页,您可以使用:

如果(!IsPostBack)
{
// 检查上一页网址
if (Request.UrlReferrer.LocalPath == / YourSolutionName / PageName.aspx
{
// 执行一些操作(在此处获取查询字符串)
}
else
{
// 执行其他操作
}
}







- Amit


  string  pagename = Master.GetIncomingVal(  param  param ); 
if (pagename == 1
node = SiteMap.Provider.FindSiteMapNodeFromKey( 〜/ CategoryManagement.aspx?param = 1);







添加了这个先生的面包屑逻辑


I have a page that is being redirected from two different places. here is the sitemap code :-

<siteMapNode url="~/ProductsIndex.aspx" title="Product Management" description="Products Details">
    <siteMapNode url="~/AddNewProducts.aspx" title="Product Identification" description="Product Identification" />
</siteMapNode>

 <siteMapNode url="~/StoreAdminIndex.aspx" title="Store Administration" description="Store Administration">
 <siteMapNode url="~/AddNewProducts.aspx" title="Product Identification" description="Product Identification" />
</siteMapNode>


After searching on net I got following answer :- We need to add any query string.

 <siteMapNode url="~/StoreAdminIndex.aspx" title="Store Administration" description="Store Administration">
 <siteMapNode url="~/AddNewProducts.aspx?S=1" title="Product Identification" description="Product Identification" />
</siteMapNode>


But When I am using this code and I am passing some other querystring value the correct sitemap is not showing. Eg. when I am redirecting to AddNewProducts.aspx page, It is like AddNewProducts.aspx?S=1&SId=7913 (Here we have one more query string SId).

And I don't want to use Session object to hold the SId.

Any Idea? how to solve this issue?

Here is the code : When I am using following code, breadcrumb is coming fine :-

Response.Redirect("~/AddNewProducts.aspx?S=1", false);


It's working fine. but when I am using following code :

Response.Redirect("~/AddNewProducts.aspx?S=1&SId=" + hdnStoreId.Value.ToString(), false);



It's showing first breadcrumb. It's not working.

Using QueryString in sitemap is bad idea either. Two recoganize the previous page, you can use this:
if( !IsPostBack )
{
     //Check with the previous page url
     if(Request.UrlReferrer.LocalPath == "/YourSolutionName/PageName.aspx")
     {
         //Perform some operations(Get the query string here)
     }
     else
     {
         //Perform other operations
     }
}




--Amit


string pagename = Master.GetIncomingVal("param", "param", "");
        if (pagename =="1")
            node = SiteMap.Provider.FindSiteMapNodeFromKey("~/CategoryManagement.aspx?param=1");




Added this begore bread crumb logic