c#


ASP.NET Webforms IHttpModule Singleton


I have a class that implements IHttpModule in a separate assembly from a website. The module implementation intercepts requests and rewrites urls for the website.
The mappings are stored in a class with the requested url and the destination url.
Is the second example, MTSingleton, from http://devhood.com/Tutorials/tutorial_details.aspx?tutorial_id=486 suitable for creating the mapping list? Is there a better approach from within the module implementation?
Edit: My bad, this is for IIS 6.0 and .NET 3.5 SP1
Sounds like you're looking to create the mappings object once in your app cycle. It sounds like you're trying to prevent this from being created over and over per request. (Please clarify if I'm wrong.)
Look at the methods on IHttpModule. Assuming you're working with IIS 7.0, the ASP.Net lifecycle will show that the Init() method is fired once. Meaning, it's fired once per application lifecycle. So, fire up the web server, first request will kick Init() into gear, then subsequent requests don't need to fire it until the web server application cycle is refreshed.
You should be able to safely move your mappings creation code into the Init() method, which should provide you with the safeguards you're seeking with a multi-threaded singleton type of initialization. You should still have multi-threaded safeguards around your mapping object, but the IHttpModule's Init() method should give you the fire-once-and-done effect you're seeking.

Related Links

37Signals OAuth C# example
Multithreaded Batch Processing (SELECT and UPDATE) [.NET][DB2]
Redirecting new tab OR browser on button click.(Response.Redirect) in asp.net C#
Calling c++ clr dll in c# silverlight
Semaphore WaitOne not operating correctly
Using Ninject 3.0 for a given code
using SqlParameterCollectionExtensions
Populating a Html.Listbox with all ASP.NET users
Something similar to C# .NET Generic List in java
Load arraylist into a TextBox
Hook a custom function for label's click event
VS2010 Project doesnt build but doesnt show any errors or warnings
Locating ASP Sitemap tree structures child nodes using Selenium webdriver
Post Array as JSON to MVC Controller
Wpf toggle button content on click
Kinect Not Showing Color Image

Categories

HOME
grizzly
glsl
highmaps
x86-64
data-modeling
azure-resource-manager
angularjs-directive
jshell
uml-designer
doctrine2
google-app-maker
velocity
dynamics-crm-2011
virtualenv
multibinding
template10
ringcentral
alert
udeploy
webgl-earth
smali
connection-pooling
procedural-generation
ecmascript-2017
poisson
android-xml
angular-schema-form
key-bindings
login-required
loopback
openvms
pyenv
azure-vm-scale-set
javafxports
azure-storage-files
outlook-2010
abide
stencyl
framebuffer
ui-grid
ssdp
jvisualvm
uitextview
definition
amazon-rds-aurora
android-doze-and-standby
qtwebkit
jks
jenkins-2
noise
visualizer
node-java
critical-section
grib
was
blitz3d
instaparse
gdi
diameter-protocol
system-integration
razorengine
pyshark
innertext
android-progressbar
trendline
alchemy
music-player
hana-sql-script
nslocalizedstring
cascading
kramdown
ruby-1.8.7
updating
om
exchange-server-2007
musicbrainz
first-order-logic
nmock
web-standards
glog
shunting-yard
qxorm
fiware-health
quickfixn
method-overloading
conditional-comments
parsefloat
enquire.js
nativequery
adabas
mysql-error-1146
code-complete
octokit
caroufredsel
ia-32
pyxplot
spawn
linqdatasource
ncml
systrace
commonsware
ruby-1.9
flexbuilder
cryptolicensing
for-xml
dynamic-scope
datadude
cross-cutting-concerns
high-load
asp.net-1.1

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App