Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3801714
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:05:36+00:00 2026-05-19T14:05:36+00:00

I needed to create a simple fast login form for an internal company project

  • 0

I needed to create a simple fast login form for an internal company project I’m working on. I saw this tut on how to do it using vb – looked really fast and easy. I ran it through a converter to change it to C# but when I load the page, this is the error I get:

CS0103: The name 'Session' does not exist in the current context

With the following code:

<script runat="server">
    public void Login(object s, EventArgs e)
    {
        if (tbUserName.Text == "admin" & tbPassword.Text == "admin")
        {
            Session("Admin") = true;
            Response.Redirect("Dashboard.aspx");
        }
        else
        {
            Session("Admin") = false;
            litLogin.Visible = true;
            litLogin.Text = "<p>Sorry you have provided incorrect login details.</p>";

        }
    }
</script>

EDIT Adding brackets helps on the login page, but on the page im trying to protect you have to check for the session like this:

    <form id="form1" runat="server">
<script runat="server">
    protected void Page_Load(object sender, System.EventArgs e)
    {
        if (Session["Admin"] != true)
        {
            Response.Redirect("Login.aspx");
        }
    }

</script>

And it throws CS0019: Operator '!=' cannot be applied to operands of type 'object' and 'bool'

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T14:05:37+00:00Added an answer on May 19, 2026 at 2:05 pm

    In C#, you need to use [and ] for indexers.

    In other words, replace

    Session("Admin")
    

    With

    Session["Admin"]
    

    In response to your edit:

    if (Session["Admin"] != true)
    

    Should be cast to bool, so you should try:

    if (!(bool)Session["Admin"]) 
    

    (No need to compare a boolean value with true/false)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I needed to create an application using Struts2 as MVC,Hibernate for data access and
Can anyone help me to create a simple viewing of cam using just a
I am trying to Create a simple Tcp Server in C++ using Boost ASio
Just trying to do a simple view spec. When I first create this spec
This is probably a very simple problem but I'm trying to create an array
I have to create a simple WebApplication with Java which shows a Login Dialog
I needed to create some PDF document , that can set background color of
What CSS is needed to create such an HTML layout: +--[li]---------------------------------------------+ |+--[div]-------------------------------------++---+| || A
I recently needed to create speech bubbles. To create the little triangular tip at
So I came to a point where I needed to create a custom query

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.