By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,219 Members | 1,745 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,219 IT Pros & Developers. It's quick & easy.

Context and global.asax

P: n/a
Hi,

I load my website settings inside the global.asax file. For this I have to
use the context, to get the roles from the current browsing client.

The problem is that there is no context at that time. (no reference) When I
add these code
lines (from global.asax) inside an aspx file, then it works. Because there
is a context.

How can I use this code inside the global.asax file?

I tried it in this:
protected void Application_BeginRequest(Object sender, EventArgs e) {}
protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{}

But this did not work. I'm using asp.net 2.0.

Hope someone can help.
Nov 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi,
I'm not very clear of what you mean with contex and roles, are you trying to
access Win auth? If so do this:

protected void Session_Start(Object sender, EventArgs e)
{
string login = WindowsIdentity.GetCurrent().Name.Substring(
WindowsIdentity.GetCurrent().Name.LastIndexOf(@"\" )+1 );
Session["SystemUser"] = login ;
}
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Arjen" <bo*****@hotmail.com> wrote in message
news:de**********@news1.zwoll1.ov.home.nl...
Hi,

I load my website settings inside the global.asax file. For this I have to
use the context, to get the roles from the current browsing client.

The problem is that there is no context at that time. (no reference) When
I add these code
lines (from global.asax) inside an aspx file, then it works. Because there
is a context.

How can I use this code inside the global.asax file?

I tried it in this:
protected void Application_BeginRequest(Object sender, EventArgs e) {}
protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{}

But this did not work. I'm using asp.net 2.0.

Hope someone can help.

Nov 17 '05 #2

P: n/a
I use form authentication.

When a user request a page it must first load some settings. These settings
will be placed inside the context.items. I can add this method in all pages
but that is not what I want. Easier will be one declaration...

This loading happens inside the global.asax file. This way it load
automaticly the settings, no matter what page the user request. This is what
I want.

Now the loading method uses some information from the current browsing
client. It want to know the roles from the current browsing client. I can't
get these from inside the global.asax file. This is the problem. I get the
messege that the object is not set to a reference.

When adding/calling this method from an aspx file then it works... I want
that it works inside the global.asax file.

This is the problem, hope someone haves a solution.

Thanks!
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us>
schreef in bericht news:%2***************@TK2MSFTNGP14.phx.gbl...
Hi,
I'm not very clear of what you mean with contex and roles, are you trying
to access Win auth? If so do this:

protected void Session_Start(Object sender, EventArgs e)
{
string login = WindowsIdentity.GetCurrent().Name.Substring(
WindowsIdentity.GetCurrent().Name.LastIndexOf(@"\" )+1 );
Session["SystemUser"] = login ;
}
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Arjen" <bo*****@hotmail.com> wrote in message
news:de**********@news1.zwoll1.ov.home.nl...
Hi,

I load my website settings inside the global.asax file. For this I have
to
use the context, to get the roles from the current browsing client.

The problem is that there is no context at that time. (no reference) When
I add these code
lines (from global.asax) inside an aspx file, then it works. Because
there is a context.

How can I use this code inside the global.asax file?

I tried it in this:
protected void Application_BeginRequest(Object sender, EventArgs e) {}
protected void Application_AuthenticateRequest(Object sender, EventArgs
e) {}

But this did not work. I'm using asp.net 2.0.

Hope someone can help.


Nov 17 '05 #3

P: n/a
What do you mean by 'roles'.
Can you be more specific about what you want to do in global.asax?

--
Vadym Stetsyak aka Vadmyst

"Arjen" <bo*****@hotmail.com> wrote in message
news:de**********@news1.zwoll1.ov.home.nl...
Hi,

I load my website settings inside the global.asax file. For this I have to
use the context, to get the roles from the current browsing client.

The problem is that there is no context at that time. (no reference) When I add these code
lines (from global.asax) inside an aspx file, then it works. Because there
is a context.

How can I use this code inside the global.asax file?

I tried it in this:
protected void Application_BeginRequest(Object sender, EventArgs e) {}
protected void Application_AuthenticateRequest(Object sender, EventArgs e)
{}

But this did not work. I'm using asp.net 2.0.

Hope someone can help.

Nov 17 '05 #4

P: n/a
Hi,

Okay, after reading my post back... it is not realy reading all the roles it
is checking the roles.

I use this:
HttpContext.Current.User.IsInRole(role);

See also my post on 15:19.

Thanks.

"Vadym Stetsyak" <va*****@ukr.net> schreef in bericht
news:%2****************@TK2MSFTNGP14.phx.gbl...
What do you mean by 'roles'.
Can you be more specific about what you want to do in global.asax?

--
Vadym Stetsyak aka Vadmyst

"Arjen" <bo*****@hotmail.com> wrote in message
news:de**********@news1.zwoll1.ov.home.nl...
Hi,

I load my website settings inside the global.asax file. For this I have
to
use the context, to get the roles from the current browsing client.

The problem is that there is no context at that time. (no reference) When

I
add these code
lines (from global.asax) inside an aspx file, then it works. Because
there
is a context.

How can I use this code inside the global.asax file?

I tried it in this:
protected void Application_BeginRequest(Object sender, EventArgs e) {}
protected void Application_AuthenticateRequest(Object sender, EventArgs
e)
{}

But this did not work. I'm using asp.net 2.0.

Hope someone can help.


Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.