473,405 Members | 2,261 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,405 software developers and data experts.

Custom PageHandlerFactory and Session-Context

Hi

I'm using a custom PageHandlerFactory as it's used in Microsofts p&p
WebClient Software Factory.
The problem is, that I cannot use Sessions now;
HttpContext.Current.Session is null.
When I use the standard PageHandlerFactory instead, all works fine.
What do I have to do, to enable SessionState with my custom
PageHandlerFactory?

Here's my PageHandlerFactory-class:

public class CustomPageHandlerFactory : PageHandlerFactory,
IRequiresSessionState
{
const string _appSettingKey = "ClientIdMapperEnabled";

public override System.Web.IHttpHandler
GetHandler(System.Web.HttpContext context, string requestType, string
virtualPath, string path)
{
Page page = (Page) base.GetHandler(context, requestType,
virtualPath, path);
page.Init += new System.EventHandler(page_PreInit);

PresentationFactory factory = new PresentationFactory();
factory.InitializeView(page);

SessionStateUtility.AddHttpSessionStateToContext(c ontext);

return page;
}

void page_PreInit(object sender, EventArgs e)
{
RenderControlIdMap((Page)sender, HttpContext.Current);
}

private void RenderControlIdMap(Page page, HttpContext context)
{
string mapperEnabledSetting =
ConfigurationManager.AppSettings[_appSettingKey];
bool addMapper = false;
if (!String.IsNullOrEmpty(mapperEnabledSetting) &&
Boolean.TryParse(mapperEnabledSetting, out addMapper))
{
if (addMapper)
{
page.Controls.Add(new ClientIdMapper());
}
}
}
}

Thank you
Daniel

Oct 17 '06 #1
0 2416

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

Similar topics

6
by: John Lau | last post by:
Hi, I am looking at the MS KB Article 306355: HOW TO: Create Custom Error Reporting Pages in ASP.NET by Using Visual C# .NET This article describes how to redirect errors to a custom html...
2
by: mohyneenm | last post by:
hi, as i understand we can read session or cache objects from a custom class using httpContext.Current.Session("..."). Is there a way to add/modify Session variables from the custom class?...
5
by: bryan | last post by:
If I understand correctly, I can write a custom handler for a given extension (say .abcd files) by writing a class that implements the IHttpHandler interface and then registering it in my web...
6
by: Shimon Sim | last post by:
Hi I am working on application that need to hold custom user information - Last and first name, email, some other domain related information. I used to create Base class for all my pages. The base...
4
by: matt.delvecchio | last post by:
hello, i understand the usefulness of having custom base classes when it pertains to common methods or custom handling of events (say, overriding all pages OnError and sending out an email of...
2
by: satisharas | last post by:
Hello, I am trying to write a custom session manager in ASP.NET 2.0 using oracle as the backend. I want to know how the session expires in web garden and we are using NLB (a session can be...
0
by: Pieter | last post by:
Hi, I'm using NHibernate 1.2 (CR1), and I'm using a custom list (inherited from BindingList(Of T) ) for all my lists. The NHibernate documentation told me that I had to implement...
1
by: =?Utf-8?B?YW5vbnltb3Vz?= | last post by:
I'm working on a Web Application where we control access to our Web Pages by using Roles. We assign which roles can view which web pages in our Web.sitemap file. Due the nature of our Application...
3
by: PJ6 | last post by:
I have this little tidbit in system.web in my web.config file, to allow the handling of requests ending in ".res": <httpHandlers> <remove verb="*" path="*.res"/> <add verb="*" path="*.res"...
7
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: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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
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...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.