日期:2014-05-20  浏览次数:20426 次

为什么会出现“请求在此上下文中不可用”呢?
我做了一个用户控件,此用户控件中只有一个控件(SiteMapPath)
并将此用户控件放在母版页中,
在运行时出现如题的提示!
用户控件中的代码如下:

protected   void   Page_Load(object   sender,   EventArgs   e)
        {
                SiteMap.SiteMapResolve   +=   new   SiteMapResolveEventHandler(SiteMap_SiteMapResolve);
        }

        SiteMapNode   SiteMap_SiteMapResolve(object   sender,   SiteMapResolveEventArgs   e)
        {
                SiteMapNode   currentNode   =   SiteMap.CurrentNode.Clone(true);

                int   albumCategoryid;
                if   (Request.QueryString[ "cid "]   !=   null)
                {
                        albumCategoryid   =   Convert.ToInt32(Request.QueryString[ "cid "]);
                }
                else
                {
                        albumCategoryid   =   0;
                }

                if   (albumCategoryid   !=   0)
                {
                        currentNode.Url   =   currentNode.Url   +   "?cid= "   +   albumCategoryid.ToString();
                        currentNode.Title   =   "动态生成 ";
                }

                return   currentNode;
        }


提示说,Request.QueryString[ "cid "]这行有问题,不知为什么?
我现在想主要解决的问题是:
如何能够修改页面导航的地址及名称
我用的是SiteMapPath控件和web.sitemap
但是这不能满足我的要求,因为有些地址是动态,比如
www.hxling.com/album/albums.aspx?cid=1
www.hxling.com/album/albums.aspx?cid=1&aid=1
这样地址
在网上搜索了很多,看了天轰穿的动态修改内存中的地址,有点不好使!

我的站点地图文件如下:
<?xml   version= "1.0 "   encoding= "utf-8 "   ?>
<siteMap   xmlns= "http://schemas.microsoft.com/AspNet/SiteMap-File-1.0 "   >
    <siteMapNode   url= "~/default.aspx "   title= "首页 "     description= " ">
            <siteMapNode   url= "~/album/default.aspx "   title= "我的相册 "     description= "我的相册 "   >
                    <siteMapNode   url= "~/album/albums.aspx "   title= "相册类别 "   description= "相册类别 ">
                                <siteMapNode   url= "~/album/photos.aspx "   title= "相册名称 "   description= "相册名称 "> </siteMapNode>
                    </siteMapNode>