我想檢查ASP.NET網站(WebForms)中會話的值。 所以我試圖做的是:我無法獲取會話的值並在if()語句中使用它
// This file called 'Encryptor.cs' and is located under the 'App_Code' folder.
using System;
using System.Data;
using System.Data.OleDb;
using System.Security.Cryptography;
using System.Text;
public static class Encryptor
{
public static bool CheckLoginStatus()
{
bool LoginStatus = false;
if ((string)Session["username"] == null)
{
LoginStatus = true;
}
return LoginStatus;
}
}
我不斷收到這樣的信息:「‘會議’的名稱不在當前環境下存在的。」 我該如何解決它?
看看這個帖子:如何從任何類訪問會話變量ASP.NET?](http://stackoverflow.com/questions/621549/how-to-access-session-variables-from-any-class-in-asp-net)接受的答案很不錯。 – scheien
謝謝!它工作 –