473,657 Members | 2,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

forcing code to run - httpmodule etc.


Let's say i have something, that will eat up a lot of cpu cycles, that i
want to run for the whole webpage( asp.net application and all subfolders
underneath). What's the best way to accomplish this? I can't have anyone
'turn off' this feature or atleast not anyone who is not an administrator on
the box(win 2k3). If the check fails i want any asp.net request to not
return the page they requested but an error message.
I implemented it as an http module that checks given a timespan. So it does
a check every 24 hours etc. If the check fails it will return an http status
code of 503 with a specific error msg. I know it's kind of drastric but thats
what the guys asked for. Kill any request that comes in once it fails and
until the admin addresses the issue.

I would like to know the best way to approach this. Should i put this in the
web.config of the system([1])? Or the machine.config? I notice a power user
can modify these files.. is it safe to deny everyone but administrators to
write to this file?

[1]
C:\windows\Micr osoft.NET\Frame work\v2.0.50727 \CONFIG

Cisco
Jun 17 '06 #1
3 1290
Hi Cisco,

Thank you for your post.

After reviewing the problem description, I am not clear on some points.
Could you please help me on the following questions so that we can work
more closely?
1) What do you mean "eat up a lot of cpu cycles, that i want to run for the
whole webpage"?
2) When you mean "the check fails", does that mean check for administrator
privilege?

As for the NTFS security of web.config or machine.config, I think the
ASP.NET worker account will not need writing access to the file, therefore
just give full access to the administrators would be ok.

If there is anything you like to add, please feel free to reply here. I am
glad to work with you on it.
Regards,
Walter Wang
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 19 '06 #2
Walter, my response is inline.

"Walter Wang [MSFT]" wrote:
Hi Cisco,

Thank you for your post.

After reviewing the problem description, I am not clear on some points.
Could you please help me on the following questions so that we can work
more closely?
1) What do you mean "eat up a lot of cpu cycles, that i want to run for the
whole webpage"?
Well something that is cpu intensive or takes a long time. I need to check
this throughout the lifetime of the server but i don't necessarily have to(or
want to) check it every request.
2) When you mean "the check fails", does that mean check for administrator
privilege?
Well basically i need to read something from a slow hardware device. The
check is something specific about that hardware. I want this check to be done
at a specific interval(hours) but once it fails i want to return a specifc
error and return a specific http status code. i want any request after that
to fail with user defined error message so that the admin can address the
problem. Currently i'm accomplishing this by creating an http module and
adding it to the web.config but i want to see what the best approach is. I
don't want any user to be able to remove this http module from the asp.net
page lifecycle.
if( CheckIfHardware Fails() ) {
// set response to 503 and end request completely
// write out some friendly message to the administrator so he can
correct the
// hardware issue
}

As for the NTFS security of web.config or machine.config, I think the
ASP.NET worker account will not need writing access to the file, therefore
just give full access to the administrators would be ok.

If there is anything you like to add, please feel free to reply here. I am
glad to work with you on it.

Appreciate it!!

Cisco

Regards,
Walter Wang
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 19 '06 #3
Hi Cisco,

Thank you for your update.

I think using an HttpModule here is reasonable. Following is the official
MSDN documentation about ASP.NET Required ACLs:

#ASP.NET Required Access Control Lists (ACLs)
http://msdn2.microsoft.com/en-us/library/kwzs111e.aspx

Another approach in my opinion would be using a timer to check the hardware
periodically, and sets an application variable when the check failed. You
check the application variable in Application's OnBeginRequest event, if it
failed, threw an exception.

Some example code:

void Application_Sta rt(object sender, EventArgs e)
{
Timer t = new Timer(3000);
t.Enabled = true;
GC.KeepAlive(t) ;
t.Elapsed += new ElapsedEventHan dler(t_Elapsed) ;
Application["timer"] = t;
}

void t_Elapsed(objec t sender, ElapsedEventArg s e)
{
if (checkHardwareF ailed()) {
Application["failed"] = "1";
// you might then disable the timer since the application needs
restart anyway
}
}

void Application_OnB eginRequest(obj ect sender, EventArgs e)
{
string status = Application["failed"] as string;
if (status == "1")
{
throw new Exception("Hard ware check failed!");
}
}

This way you don't need to use an HttpModule and don't need to modify
web.config or machine.config.

Hope this helps. Please feel free to post here if anything is unclear.
Regards,
Walter Wang
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 20 '06 #4

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

Similar topics

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...
2
3430
by: Rob Mayo | last post by:
What I'm trying to do is Create an ASP.Net app that has both Windows-authenticated users and Anonymous users. The idea is this: When authenticated users attempt to access the site, their credentials are passed to the Request, and I use the DOMAIN\USER value via the AUTH_USER server variable to access their accounts. These people would never have to log in to the app, only their machines on the network. When anonymous users attempt to...
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?
2
1298
by: MWells | last post by:
I have a simple project server which shares files from within our network. The ASP.NET front end uses a database to authenticate users, and then based on their permissions, reaches across the network to various project folders and enumerates the files within. When clicked on, the file is retrieved and streamed back across the network to the webserver and then back to the requestor. All of this works great; however, since the original...
2
4580
by: walter | last post by:
Hi there, I know there is pool of HttpApplications, and for each request coming in, HttpRuntime will dedicate one from pool to serve the request. My questions are : 1. since HttpModule is plug into the process, does each instance of HttpApplication keep its own set of HttpModule instance or HttpModules are shared among all HttpApplication instances? 2. In case of HttpApplication keep its own set of HttpModule, does the HttpModule...
0
1129
by: mattdev1000 | last post by:
Hello, I have an HttpModule that uses a lazy fetch to a secondary tier for calculating some values (the calculation is can be multisecond in the worse case). The HttpModule spins up a thread to listen for a response from this 2nd tier and will cache the results in a large table for service subsequent requests. I notice that the HttpModule will unload from time to time and realize this is normal behavior but was wondering if there was...
4
2076
by: Bac2Day1 | last post by:
I've got a HTTPMODULE that I need to be included on some pages within my site, but not others. This will allow security (the purpose of the module) on most parts of my site, but I need to bypass loading the httpmodule on web services within my site. I do not have direct access to manipulate the module, so I need to figure out a way to either enable/add the module on only certain pages, or a way to disable a module on certain pages. Any...
1
1800
by: =?Utf-8?B?TmF2YW5lZXRoLksuTg==?= | last post by:
Hello, I am designing a HTTPModule that tracks and logs all pages visited by user. I am succeeded in that. Now to provide much better experience for the person who monitor's these logs, I need to track the button's clicked on the pages by user also. Is there any way to do this using HTTPModule ? Is it possible to handle which event is going to fire , from an HTTPModule ? I mean if button1 is clicked, is it possible to find out button1...
3
1833
by: Joseph Geretz | last post by:
I'm implementing a web application whose purpose in life is to act as a data conduit. Data is posted to my Web app in XML format, my application examines the data and forwards it onward by posting it to the appropriate upstream server. Since transaction processing is largely identical regardless of the transaction details (these will be handled by an upstream sever) I'm thinking of implementing my application as an HttpModule. But I'm...
0
8382
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8297
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
8717
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...
1
8498
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8600
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...
1
6162
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5629
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();...
1
2726
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
2
1930
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.