473,654 Members | 3,251 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom HttpModule & HttpSessionStat e

Hi,

I'm using a custom HttpModule.
Implementation as follow:

internal class CustomHtttpModu le:IHttpModule
{
public void Init(HttpApplic ation app)
{
app.Authenticat ionRequest += new EventHandler(On Authenticate);
}

private void OnAuthenticate( object sender, EventArgs e)
{
HttpContext context = HttpContext.Cur rent;
HttpCookie httpCookie =
context.Request .Cookies[FormsAuthentica tion.FormsCooki eName];
if (httpCookie != null)
{
FormsAuthentica tionTicket ticket =
FormsAuthentica tion.Decrypt(ht tpCookie.Value) ;
if (ticket!=null)
{
CustomPrincipal user = new CustomPrincipal (ticket);
System.Web.Http Context.Current .User = user;
}
}
}
}

Authentication works but i'm losing Session when i try to enter in a
Web Site.
Can you help?
Nov 18 '05 #1
3 5504
This is truly a shot in the dark.Is it possible that your constructed
CustomPrincipal is not behaving like others ???
Because the attempt to acquire session state occurs after Authentication (of
course) and it might be using something about the User. Can you try to trace
the calls into your Principal and see if they are actually getting acquired
correctly or is it ending up with new sessions all the time.

--
Girish Bharadwaj
http://msmvps.com/gbvb
"Gilles" <gi************ ***@accorservic es.com> wrote in message
news:40******** *************** ***@posting.goo gle.com...
Hi,

I'm using a custom HttpModule.
Implementation as follow:

internal class CustomHtttpModu le:IHttpModule
{
public void Init(HttpApplic ation app)
{
app.Authenticat ionRequest += new EventHandler(On Authenticate);
}

private void OnAuthenticate( object sender, EventArgs e)
{
HttpContext context = HttpContext.Cur rent;
HttpCookie httpCookie =
context.Request .Cookies[FormsAuthentica tion.FormsCooki eName];
if (httpCookie != null)
{
FormsAuthentica tionTicket ticket =
FormsAuthentica tion.Decrypt(ht tpCookie.Value) ;
if (ticket!=null)
{
CustomPrincipal user = new CustomPrincipal (ticket);
System.Web.Http Context.Current .User = user;
}
}
}
}

Authentication works but i'm losing Session when i try to enter in a
Web Site.
Can you help?

Nov 18 '05 #2

Thanks for reply.

I'm always retreiving the custom Principal from HttpContext.

In fact, when i use PrincipalPermis sion Attribute in a page, the method
customPrincipal .IsInRole() is called.
Then i try to get roles from HttpContext.Cur rent.Session and have
session null.

I did not find out a way to get the current session.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3

Hello,

Not sure if this will help or not, but I had to move most of my
authentication code from my Authenticate event to my AcquireRequestS tate
event because thats where the SessionStateMod ule assocaiates the session to
the current request.

Hope this helps.

Todd

"CHRISTOPHE Gilles" wrote:

Thanks for reply.

I'm always retreiving the custom Principal from HttpContext.

In fact, when i use PrincipalPermis sion Attribute in a page, the method
customPrincipal .IsInRole() is called.
Then i try to get roles from HttpContext.Cur rent.Session and have
session null.

I did not find out a way to get the current session.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #4

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

Similar topics

0
1242
by: Joshua Belden | last post by:
I have a custom httpmodule that looks at the HttpApplication.Context.Session.SessionId. I've noticed that it returns a unique SessionId every time, even if the requests are made by the same browser on the same visit. If I set or access any Session variable from either the HttpModule or the aspx page the request is using it fixes this and all subsequent SessionIds for the visit are the same, which is what I would expect by default. Does...
2
1643
by: moid | last post by:
i need help so that i can initialize page thorugh http module or handler i know it is possible through handler using ProcessRequest but im aint configure the things out. i need some thing like this Initialises form => fill's datagrid through dataset using commandfactory/command => load form
3
3750
by: Michael Iantosca | last post by:
I have a custom attribute that I attach to certain pages in my application and I want to inspect each page request as it is made to see if the custom attribute is attached to the underlying page class. If is attached I want to perform some action. How can I access custom attributes from an HttpModule? I have to pass a target to the System.Attribute.GetCustomAttribute() call to attempt to retrieve the attached attribute. I tried to access...
3
7248
by: David B. Bitton | last post by:
For some odd reason, despite the fact that I assign my own custom IPrincipal to the HttpContext.User property in an HttpApplication.AuthenticateRequest event handler inside of an IHttpModule, when I check the Page.User property, it's a WindowsPrincipal and not _my_ custom Iprincipal. Why would this be? .... using System;
1
618
by: coollzh | last post by:
I want to remove asp.net default Authentication and Authorization HttpModule handler and add my custom Authentication and Authorization HttpModule. in my custom Authentication HttpModule Handler,i assign Iprincinpal(with some roles) to Current user , but how can i Authorizated the Current request page to the current user just as ASP.NET Authorization behavior really, not using Response.Redirect("login.aspx") or Server.Transfer("login.aspx")
1
1857
by: Mike Kline | last post by:
Hi There! How do I make the Objects in the custom made HttpModule available to ASPX page or ASCX controls without requiring an object reference? For example, SessionState HttpModule made the Session object available throughout the ASP.NET application without needing to have a reference to SessionState HttpModule. So how do I expose my own objects from my own custom HttpModule available throughout the ASP.NET application?
5
7302
by: Miguel | last post by:
ey, I m trying to make a new httpmodule but the session object is null. I m implementing IReadOnlySessionState but it keep on being null. I m novice in this enviroment, does anybody know what's happening? thanks Miguel
0
1411
by: Thomas | last post by:
in .net 1.1 we successfully use a HttpModule to catch 404 / 403.1 html errors. after migrating to .net 2.0, this modules is broken in a very, very strange way. we have defined a wildcard applicatio mapping to the .net 2.0 isapi dll: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll with "check if file exists" disabled. the HttpModule "RedirectMissing" is called upon every request to the
7
4682
by: ADN | last post by:
Hi, I am creating a custom HTTPModule to intercept the request of when the user is attempting to retrieve a session variable. For instance, if I set a session variable in my code like so: session = "Hello World"; When the request for that session variable "myString" is attempted to be retrieved, I would like to intercept that request like so: if (Request is for session variable "myString")
0
8290
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8708
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8594
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7307
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5622
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2716
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.