473,395 Members | 1,972 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,395 software developers and data experts.

Context and global.asax

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
4 4635
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Arjen | last post by:
Hi, I use form authentication for my asp.net 2.0 webapplication. When a user request a page it must first load some settings. These settings will be placed inside the context.items. I can add...
2
by: Mark Olbert | last post by:
I have a v1.1 webapp that works fine on two different servers (my development machine and a Verio-hosted site). However, it blows up on a MaximumASP-hosted site at a particular line: private void...
0
by: Arjen | last post by:
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...
8
by: Rob T | last post by:
When I was using VS2003, I was able to compile my asp.net project locally on my machine and copy it to the production server and it would run just fine. I've now converted to VS2005. The project...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.