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

How can i scale a cube to only one direction left?
Why delegate declaration requires identifier to be mentioned?
Unable to find database name using EntityCommandExecutionException
How to Ignore the list if values are empty in c#
Why is Async Void so bad? [duplicate]
One ViewModel two Views with MVVMLight in WPF
Find n-level nested SubDocument MongoDB
Open asp LinkButton in a new tab
Creating a Font using Floating Point Size returns incorrect Sized Font
System.Web.HttpUtility.HtmlDecode giving different results
C# binding datagridviewcomboboxcolumn to list display, formatting, preferred Size error
How to design my online Game Server for Unity3d?
Decrypt C#-encrypted data in C++ using Windows AES crypto provider
What is the replacement of CryptoConfig class in .NETCore?
C# Service Reference error: A child element named 'element' with same key already exists
How to remove broken background of ListViewItem In UWP?

Categories

HOME
classification
joomla
virtual-machine
gsm
nagios
gaussian
mingw
swap
rmarkdown
ethereum
minimax
angular-universal
minimum
popup
greensock
draw2d
django-rest-auth
fibonacci
smali
bootstrap-accordion
struts
ppp
core-animation
knapsack-problem
rollupjs
windows-mobile
pydub
typeorm
delphi-2010
ng2-bootstrap
choco
postgresql-9.6
snapkit
ports
tunnel
border-layout
perf
autodesk-data-management
intervention
servicebus
django-cors-headers
chrome-custom-tabs
easyquery
geminabox
react.rb
cc
reloaddata
petapoco
breadcrumbs
alarmmanager
konakart
audiorecord
calc
dcast
bluetooth-lowenergy-4.2
markerspiderfier
dynamics-nav
maven-antrun-plugin
tess4j
glog
esb-toolkit-2.1
bungeecord
perfect-scrollbar
douglas-peucker
xmla
iphone-6
xcode5
jsonmodel
system.io.packaging
zoneminder
nsmutableurlrequest
disparity-mapping
rpt
visual-c#-express-2010
atg-dynamo
isl
pyalgotrade
traceur
git-subtree
kernel-density
carrier
imaplib
misfire-instruction
kendo-window
ia-32
angularjs-select2
xrandr
google-checkout
symbian3
simplemembership
generator-expression
boost.build
idoc
netzke
android-memory
dancer
helicontech
opendir
for-xml
web-search
appointment
dynamic-scope
coderush-xpress
zend-acl

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