We help IT Professionals succeed at work.
Get Started

Session Asp.net admin

311 Views
Last Modified: 2012-08-13
Hi Experts,

I build a web page in asp.bet VB, in which I am integrating a very simple "CMS" by creating a page which would update a page content using the fck editor. Now my next step is to only show the edit page link to logged in users, and I am kinda stuck on how to do this. Below you can see how I am logging admin user, and how the link appears no matter if admin is logged in or no.. .
 User should see this link  if the user has authenticated as a site administrator.  How do I do this??

l
login.aspx
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="login.aspx.vb" Inherits="login" %>
<script runat="server">

Public Sub Login(ByVal s As Object, ByVal e As EventArgs)

        If UserName.Text = "admin" And Password.Text = "physician" Then
            Session("Admin") = True
            Response.Redirect("default.aspx")
        Else
            Session("Admin") = False
            LtlLogin.Text = "<p>Sorry you have provided incorrect login details.</p>"
        End If
End Sub
</script>


Protectected Page code behind


    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

        If HttpContext.Current.User.Identity.IsAuthenticated Then
            Dim MyPage As String = LCase(Left(System.IO.Path.GetFileName(Request.ServerVariables("SCRIPT_NAME")), InStr(System.IO.Path.GetFileName(Request.ServerVariables("SCRIPT_NAME")), ".") - 1))
            Response.Write("<a href='/RgvPreffered/admin.aspx?page=" + MyPage + "'>Edit this page</a>")
        End If

    End Sub

Open in new window

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE