This article is a mirror article of machine translation, please click here to jump to the original article.

View: 10854|Reply: 0

[ASP.NET] Error: A non-static field, method, or property "System.Web.UI.Page.Session.get" requires an object reference

[Copy link]
Posted on 4/26/2015 10:41:26 AM | | |

The initial statement is:

string sql = "select basename from base WHERE baseid ='" + Session["UserRights"]. ToString() + "'";

Error on execution: Non-static fields, methods, or attributes "System.Web.UI.Page.Session.get" require object references;



Later change the sentence to:

string sql = "select basename from base WHERE baseid ='" + System.Web.HttpContext.Current.Session["UserRights"]. ToString() + "'";

The sentence is executed smoothly, I hope it will be helpful to those who see it!




Previous:Acer notebook battery removal tutorial
Next:asp.net student sign-in and check-out system
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com