2
我目前正在使用:asp.net頁面認證的安全等級
protected void Page_Load(object sender, EventArgs e)
{
if (Session["SecurityLevel"] != "A") //If the logged in user is not Admin
{
//disable the following images and links
GridView1.Visible = false;
GridView2.Visible = false;
}
}
阻止網頁上的那些不具備管理員權限誰某些項目的知名度。
我的問題是:如何重寫此代碼,以阻止任何不是管理員或以用戶身份登錄的人(這些是我的網站使用的2個安全級別)的可見性?
我已經嘗試寫if (Session["SecurityLevel"] != "A" || "U")
使用OR運算符,但這不會編譯。
沒有人知道一個簡單的是我可以重寫這樣說if != admin or user
或潛在if = unauthenticated
我已經做了一些搜索和最點設置的認證方式爲形式和添加授權類的控制器或類似的東西,但我真的只需要此認證的一個頁面上我的網站在C#
asp.net網站
的感謝! if(Session [「SecurityLevel」]!=「A」&& Session [「SecurityLevel」]!=「U」) 很好用。 –