简体   繁体   中英

create dynamically session value

I'd like to create session value according to page title. If I debug the code, The session value does not appear. I can not catch any value. Can somebody help me?

Here is the my code

string pageTitle = new PageManager().GetPageNode(new Guid(SiteMapBase.GetCurrentProvider().CurrentNode.Key)).Title;
Session['"' + pageTitle + '"'] == true

Change your code to this:

string pageTitle = new PageManager().GetPageNode(new Guid(SiteMapBase.GetCurrentProvider().CurrentNode.Key)).Title;
Session[pageTitle] = true; //remove double = as it is for comparing, 
                           //also get rid of single quotes

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM