如何在web.sitemap中使用不同的URL调用两次相同的页面 [英] How to call same page twice with different url in web.sitemap
问题描述
我有一个页面正在从两个不同的地方重定向。这是站点地图代码: -
< siteMapNode url = < span class =code-keyword>〜/ ProductsIndex.aspx title = 产品管理 description = 产品详情 >
< siteMapNode url = 〜 /AddNewProducts.aspx\" title = 产品标识 description = 产品标识 / >
< / siteMapNode > ;
< siteMapNode url = 〜 /StoreAdminIndex.aspx\" title = 商店管理 description = 商店管理 >
< siteMapNode url = 〜/ AddNewProducts.aspx title = 产品标识 < span class =code-attribute> description = 产品标识 / >
< / s iteMapNode >
在网上搜索后得到以下答案: - 我们需要添加任何查询字符串。
< siteMapNode url = 〜/ StoreAdminIndex.aspx title = 商店管理 说明 = 商店管理 >
< siteMapNode url = 〜/ AddNewProducts.aspx?S = 1 title = 产品标识 description = 产品标识 / >
< / siteMapNode >
但是当我使用此代码并且我传递了一些其他查询字符串值时,没有显示正确的站点地图。例如。当我重定向到 AddNewProducts.aspx 页面时,它就像 AddNewProducts.aspx?S = 1& SId = 7913 (这里我们有一个)更多查询字符串SId)。
我不想使用Session对象来保存 SId
。
任何想法?如何解决这个问题?
这是代码:当我使用下面的代码时,面包屑就好了: -
Response.Redirect( 〜/ AddNewProducts.aspx?S = 1, false );
工作正常。但是当我使用以下代码时:
Response.Redirect( 〜/ AddNewProducts.aspx?S = 1& SId = + hdnStoreId.Value.ToString(), false );
显示第一个面包屑。它不起作用。
在站点地图中使用QueryString也是个坏主意。两个认可上一页,您可以使用:
<前一个=c#> 如果(!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
这篇关于如何在web.sitemap中使用不同的URL调用两次相同的页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!