Link to home
Start Free TrialLog in
Avatar of TonyReba
TonyRebaFlag for United States of America

asked on

Session Asp.net admin

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

ASKER CERTIFIED SOLUTION
Avatar of cjrbus
cjrbus

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of TonyReba

ASKER

ok so I commented the other approach and leave:

What DO I need to set up in my web config to manage session authentication>???
'  If HttpContext.Current.User.Identity.IsAuthenticated Then
        If Session("Admin") = True 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

Open in new window

Avatar of cjrbus
cjrbus

That's what I would do.  I don't think this requires any changes to the web.config.
Avatar of Kumaraswamy R
I thought that wcf had a json serializer built in?