Click here to Skip to main content
15,909,199 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
when user after login the user i copy the url and close the browser.again open same browser paste the url run the application i got this error:
none
Unable to cast object of type 'System.Guid' to type 'System.String'

This is my code:
C#
DataTable dtMenu = new DataTable();
                   DataSet ds = new DataSet();


                   XmlDataSource xmlDataSource = new XmlDataSource();
                   xmlDataSource.ID = "XmlSource1";
                   xmlDataSource.EnableCaching = false;

                   dtMenu = GetMenuTable();
                   ds.Tables.Add(dtMenu);

                   ds.DataSetName = "Menus";
                   ds.Tables[0].TableName = "Menu";

                   DataRelation relation = new DataRelation("Parentchild", ds.Tables["Menu"].Columns["ChildId"], ds.Tables["Menu"].Columns["ParentId"], true);

                   relation.Nested = true;
                   ds.Relations.Add(relation);

                   xmlDataSource.Data = ds.GetXml();


                   xmlDataSource.TransformFile = Server.MapPath("~/Menu.xslt");


                   xmlDataSource.XPath = "MenuItems/MenuItem";


                   NavigationMenu.DataSource = xmlDataSource;
                   NavigationMenu.DataBind();

                   linkuaername.Text =(string)Session["username"];    // here i got an error 
                   Authenticatemenu(linkuaername.Text);

Please share the information
Posted
Updated 27-Aug-13 2:55am
v5
Comments
[no name] 27-Aug-13 8:32am    
Share what information? It is no secret that a System.Guid is not a string.
krish2013 27-Aug-13 8:53am    
Hii,
It's working fine but closing the browser and open same browser i paste the url the username is not coming it's showing some default value please share your information
OriginalGriff 27-Aug-13 8:32am    
We would need to see the code you used to copy and paste the info - there are just so many ways you could have done this.
Use the "Improve question" widget to edit your question and add the relevant code fragments.
krish2013 27-Aug-13 8:53am    
Hii,
It's working fine but closing the browser and open same browser i paste the url the username is not coming it's showing some default value please share your information

1 solution

Try this:
C#
linkuaername.Text = Session["username"].ToString();
 
Share this answer
 
v2
Comments
krish2013 27-Aug-13 8:49am    
Hii ProgramFox,
It's working fine but closing the browser and open same browser i paste the url the username is not coming it's showing some default value please share your information
Thomas Daniels 27-Aug-13 8:52am    
Because if you paste the URL in the other browser, Session["username"] is not yet declared.
krish2013 27-Aug-13 8:57am    
if i paste other browser it's going login page but i paste same page username is not displayed.
Thomas Daniels 27-Aug-13 9:03am    
Of course: the other browser can't show the username if you're not logged in!

If you're logged on in one browser, then you're not immediately logged on in another browser: you have to log in a second time.
krish2013 27-Aug-13 9:10am    
please share how to declared that session["username"] in browser

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900