473,387 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

checking to see if user is authenticated

Hi,

I am learning C# and basically using a .asp net app I wrote in VB and
converting to C#.

in VB code :
If Context.User.Identity.IsAuthenticated Then
obj = Session.Item(SESSION_NAVIGATION_DATA)
Else
obj = Page.Cache.Get(CACHE_NAVIGATION_DATA)
End If

this code checks to see if for the current user they have already been
authenticated.

my problem is that when trying to write the first line in C# my intellisence
does not provide me with any methods or properites.

I am "inheriting and implementing" all my assembly (DLL) libraries I need.
HELP says that "The Context type supports the .NET Framework infrastructure
and is not intended to be used directly from your code.

How then do I do in C# that I am doing in VB.NET?

thanks

Chris
Nov 17 '05 #1
4 2102
By first line… do you mean the if statement? I ask because when I convert
your VB.NET code to C# and run it, it gives me no problems. This is what I’ve
got it as in C#, what does yours look like?

if( Context.User.Identity.IsAuthenticated )
{
obj = Session[SESSION_NAVIGATION_DATA];
}
else
{
obj = Page.Cache[CACHE_NAVIGATION_DATA];
}

Brendan
"Chris" wrote:
Hi,

I am learning C# and basically using a .asp net app I wrote in VB and
converting to C#.

in VB code :
If Context.User.Identity.IsAuthenticated Then
obj = Session.Item(SESSION_NAVIGATION_DATA)
Else
obj = Page.Cache.Get(CACHE_NAVIGATION_DATA)
End If

this code checks to see if for the current user they have already been
authenticated.

my problem is that when trying to write the first line in C# my intellisence
does not provide me with any methods or properites.

I am "inheriting and implementing" all my assembly (DLL) libraries I need.
HELP says that "The Context type supports the .NET Framework infrastructure
and is not intended to be used directly from your code.

How then do I do in C# that I am doing in VB.NET?

thanks

Chris

Nov 17 '05 #2
Hi Brendan,

well i actually have'nt tried to run the code yet, I just know i'm not
getting any intellisence. Is it necessary to see the intellisence?

"Brendan Grant" wrote:
By first line… do you mean the if statement? I ask because when I convert
your VB.NET code to C# and run it, it gives me no problems. This is what I’ve
got it as in C#, what does yours look like?

if( Context.User.Identity.IsAuthenticated )
{
obj = Session[SESSION_NAVIGATION_DATA];
}
else
{
obj = Page.Cache[CACHE_NAVIGATION_DATA];
}

Brendan
"Chris" wrote:
Hi,

I am learning C# and basically using a .asp net app I wrote in VB and
converting to C#.

in VB code :
If Context.User.Identity.IsAuthenticated Then
obj = Session.Item(SESSION_NAVIGATION_DATA)
Else
obj = Page.Cache.Get(CACHE_NAVIGATION_DATA)
End If

this code checks to see if for the current user they have already been
authenticated.

my problem is that when trying to write the first line in C# my intellisence
does not provide me with any methods or properites.

I am "inheriting and implementing" all my assembly (DLL) libraries I need.
HELP says that "The Context type supports the .NET Framework infrastructure
and is not intended to be used directly from your code.

How then do I do in C# that I am doing in VB.NET?

thanks

Chris

Nov 17 '05 #3
Does the code compile?
I think my question would be: In what method (and what class) are you
writing this code?
That class must be inheriting (directly or indirectly) from the Control
class in order to have the Context property and therefore be compilable and
have Intellisense support.
"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:EF**********************************@microsof t.com...
Hi Brendan,

well i actually have'nt tried to run the code yet, I just know i'm not
getting any intellisence. Is it necessary to see the intellisence?

"Brendan Grant" wrote:
By first line. do you mean the if statement? I ask because when I convert
your VB.NET code to C# and run it, it gives me no problems. This is what
I've
got it as in C#, what does yours look like?

if( Context.User.Identity.IsAuthenticated )
{
obj = Session[SESSION_NAVIGATION_DATA];
}
else
{
obj = Page.Cache[CACHE_NAVIGATION_DATA];
}

Brendan
"Chris" wrote:
> Hi,
>
> I am learning C# and basically using a .asp net app I wrote in VB and
> converting to C#.
>
> in VB code :
>
>
> If Context.User.Identity.IsAuthenticated Then
> obj = Session.Item(SESSION_NAVIGATION_DATA)
> Else
> obj = Page.Cache.Get(CACHE_NAVIGATION_DATA)
> End If
>
> this code checks to see if for the current user they have already been
> authenticated.
>
> my problem is that when trying to write the first line in C# my
> intellisence
> does not provide me with any methods or properites.
>
> I am "inheriting and implementing" all my assembly (DLL) libraries I
> need.
> HELP says that "The Context type supports the .NET Framework
> infrastructure
> and is not intended to be used directly from your code.
>
> How then do I do in C# that I am doing in VB.NET?
>
> thanks
>
> Chris

Nov 17 '05 #4
here is all my code exactly :

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;

namespace BBAdmin.Pages
{

public class leftnav : System.Web.UI.Page
{
public const string CACHE_NAV_DATA = "NavData";
public const string SESSION_NAV_DATA = "UserSessionNavData";

protected System.Web.UI.HtmlControls.HtmlForm Form1;

private void Page_Load(object sender, System.EventArgs e)

{
RegisterLinkButtonScript();
}

public static string GetJSHyperlinksString()
{
//this function will determine the hyperlinks available to the logged
//in user by reading the database. Default hyperlinks are constructed
//for those who are not logged in.

object objsession;
string JSHyperlinksString = string.Empty;

//check to see if the hyperlinks already exist.
//this javascript code is parsed by the worker thread into an
//unmanaged client side code whenever it is retrieved by the
//page.cache.get method
if( Context.User.Identity.IsAuthenticated )
{
objsession = Session[SESSION_NAVIGATION_DATA];
}
else
{
objsession = Page.Cache[CACHE_NAVIGATION_DATA];
}


return JSHyperlinksString;
}
}
}

"Francois Bonin [C# MVP]" wrote:
Does the code compile?
I think my question would be: In what method (and what class) are you
writing this code?
That class must be inheriting (directly or indirectly) from the Control
class in order to have the Context property and therefore be compilable and
have Intellisense support.
"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:EF**********************************@microsof t.com...
Hi Brendan,

well i actually have'nt tried to run the code yet, I just know i'm not
getting any intellisence. Is it necessary to see the intellisence?

"Brendan Grant" wrote:
By first line. do you mean the if statement? I ask because when I convert
your VB.NET code to C# and run it, it gives me no problems. This is what
I've
got it as in C#, what does yours look like?

if( Context.User.Identity.IsAuthenticated )
{
obj = Session[SESSION_NAVIGATION_DATA];
}
else
{
obj = Page.Cache[CACHE_NAVIGATION_DATA];
}

Brendan
"Chris" wrote:

> Hi,
>
> I am learning C# and basically using a .asp net app I wrote in VB and
> converting to C#.
>
> in VB code :
>
>
> If Context.User.Identity.IsAuthenticated Then
> obj = Session.Item(SESSION_NAVIGATION_DATA)
> Else
> obj = Page.Cache.Get(CACHE_NAVIGATION_DATA)
> End If
>
> this code checks to see if for the current user they have already been
> authenticated.
>
> my problem is that when trying to write the first line in C# my
> intellisence
> does not provide me with any methods or properites.
>
> I am "inheriting and implementing" all my assembly (DLL) libraries I
> need.
> HELP says that "The Context type supports the .NET Framework
> infrastructure
> and is not intended to be used directly from your code.
>
> How then do I do in C# that I am doing in VB.NET?
>
> thanks
>
> Chris


Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Luis Solís | last post by:
I have defined a class Myclass I instanciate the class and I use it in a function, and I could like check the argument type in the function, but this code don't works func (xMyclass,..): if ...
0
by: Haim Ashkenazi | last post by:
Hi A client of mine wants me to write a simple web interface for qmail's autorespond. this means that a user must authenticate with his system user/password, and then make some changes to the...
3
by: Jiho Han | last post by:
Should ASPNET user belong to the local Users group? I may have made some changes that affected my workstation setup and I am experiencing some unexpected behaviors. For example, I have my IIS...
2
by: noor | last post by:
hi, can any one tell me a javascript that can be called on mouseover event of a html link control . script can check from session either a user is login or not In the case of Login it will...
0
by: noor | last post by:
hi, can any one tell me a javascript that can be called on mouseover event of a html link control . script can check from session either a user is login or not In the case of Login it will...
1
by: noor | last post by:
hi, can any one tell me a javascript that can be called on mouseover event of a html link control . script can check from session either a user is login or not In the case of Login it will...
5
by: Shimon Sim | last post by:
I am working with LogIn control and need to set some property for profile after user is authenticated. I thought that LoggedIn event is the right place but system tells me that the property can't...
3
by: shapper | last post by:
Hello, I need to check if a user is authenticated. I tried everything I could think and find: If Membership.ValidateUser("shapper", "27lamps11") Then...
0
by: sainiamit25 | last post by:
Hi All, I want to check the permissions for two users a & b in UNIX. Which command will help me in that? I want to see which folders they have access to etc etc. Kindly help me. Cheers, Amit
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.