473,382 Members | 1,437 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,382 software developers and data experts.

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\Microsoft.NET\Framework\v2.0.50727\CONF IG

Cisco
Jun 17 '06 #1
3 1278
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( CheckIfHardwareFails() ) {
// 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_Start(object sender, EventArgs e)
{
Timer t = new Timer(3000);
t.Enabled = true;
GC.KeepAlive(t);
t.Elapsed += new ElapsedEventHandler(t_Elapsed);
Application["timer"] = t;
}

void t_Elapsed(object sender, ElapsedEventArgs e)
{
if (checkHardwareFailed()) {
Application["failed"] = "1";
// you might then disable the timer since the application needs
restart anyway
}
}

void Application_OnBeginRequest(object sender, EventArgs e)
{
string status = Application["failed"] as string;
if (status == "1")
{
throw new Exception("Hardware 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
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...
2
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...
1
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...
2
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...
2
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...
0
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...
4
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...
1
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...
3
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.