473,770 Members | 1,954 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Randomly request timeout (IIS6.0)

Hi!
I have got IIS 6.0 on Windows 2003 Server. I have installed HTTP
handler (as simple reverse-proxy) - code below. I created virtual
category with this dll and Wilcard application mapping set to
aspnet_isapi.dl l

Now everything works fine, but sometimes IIS stops working and return
'Error in /catalog Application. Request timeout...' And than i must
restart IIS (at least application pools).

Thanks for help,
Filip

Code of Handler.cs:

/*
Handler.cs; v 1.1; 2005/10/25; Filip Balicki
Script capture all references to selected in Web.config virtual
directory, and download resources from
selected (also in Web.config) remote host. (so it is work as
proxy)
*/

using System;
using System.Web;
using System.Net;
using System.Text;
using System.Text.Reg ularExpressions ;
using System.IO;
using System.Collecti ons;
using System.Configur ation;

namespace Polygon
{

public class Handler : IHttpHandler
{
string host_address
{
get
//Take local address (where this script
is installed) from
web.config
//http://my_domain/virtual_catalog/
{
return
ParseUrl(Config urationSettings .AppSettings["local_addr ess"]);
}
}
string dest_adress
{
get
//Take local address (where this script
is installed) from
web.config
//http://my_domain/virtual_catalog/
{
return
ParseUrl(Config urationSettings .AppSettings["destination_ho st"]);
}
}
public void ProcessRequest( HttpContext context)
{

string my_uri = context.Request .Url.ToString() ;
//construct real uri to remote host
string real_uri = Regex.Replace (my_uri,
host_address,de st_adress,Regex Options.Multili ne |
RegexOptions.Ig noreCase);
HttpWebRequest request = (HttpWebRequest )
WebRequest.Crea te(real_uri);
request.KeepAli ve = false;
request.AllowAu toRedirect = false;
HttpWebResponse response;
try
{
response = (HttpWebRespons e)
request.GetResp onse();
}
catch(System.Ne t.WebException we)
{
context.Respons e.StatusCode = 404;
context.Respons e.StatusDescrip tion =
"Not Found ("+we.Message+" )";
response = (HttpWebRespons e)
we.Response;
writeBody(conte xt, response);
return;
}
if (response.Statu sCode != HttpStatusCode. OK)
//Found not OK header - probably
redirect
{
context.Respons e.AddHeader("Lo cation",
response.Header s["Location"]);

context.Respons e.AddHeader("Co ntent-Type", response.Conten tType);
context.Respons e.StatusCode = (int)
response.Status Code;
}
else
{

context.Respons e.AddHeader("Co ntent-Type", response.Conten tType);
writeBody (context, response);
}
response.Close( );
context.Respons e.End();

}

public bool IsReusable
{
get
{
return true;
}
}

public string ParseUrl (string url)
{
if ((char)url[url.Length-1]!= '/')
{
url+='/';
}
return url;
}

public void writeBody (HttpContext context,
HttpWebResponse response)
{
Stream receiveStream =
response.GetRes ponseStream();
if
((response.Cont entType.ToLower ().IndexOf("htm l")>=0)

||(response.Con tentType.ToLowe r().IndexOf("ja vascript")>=0))
//if we get html or javascript use ASCI
mode
{
string body;
StreamReader readStream = new
StreamReader (receiveStream,
Encoding.Defaul t);
body = readStream.Read ToEnd();
context.Respons e.Write(body);
}
else
{
//the response is not HTML - use binary
mode
byte[] buff = new byte[1024];
int bytes = 0;
while( ( bytes = receiveStream.R ead(
buff, 0, 1024 ) ) > 0 )
{
//Write the stream directly to
the client

context.Respons e.OutputStream. Write (buff, 0, bytes );
}
}
response.Close( );
}

}

Jun 28 '06 #1
0 1280

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

Similar topics

1
2791
by: Phil S | last post by:
My server is randomly restarting every few minutes or so, and I can't figure out why. What would cause this to happen, aside from some evil person sitting at the console? I did manage to catch it in the act, and get a stack trace, but it doesn't really tell me a whole lot. Anyone know what causes this, or what diagnostics I can use to help pinpoint the cause? at Hansen.UI.Web.Global.Application_End(Object, EventArgs) at...
2
5621
by: James M. | last post by:
I have 2x Front-end Web servers (Win2003 Ent IIS6.0), setup with NLB (single Affinity, also using SQLServer session state) that are hosting a few .NET ASP web applications under the Default Website in IIS, and accessing via a Intranet LAN (this is not publicly available). NETWEB1: NIC1 172.16.17.220 172.16.17.244 (NLB Virtual IP) NIC2 172.16.17.221
11
2345
by: Ed Dearlove | last post by:
**Also posted in inetserver.iis newsgroup as I am unsure of where the problem lies** Hi, I have a strange problem, or I may just be stupid, but wondering if anyone can help with this one: We receive a large number of very simple POST requests to our vb.net web
5
5292
by: fbwhite | last post by:
I know this issue has been brought up many times, but I have tried many of the solutions to no avail. I wanted to give my specific case to see if someone could be of any help. We are using the sessionstate inproc mode and users are randomly losing their session. I do not believe it is happening across all users at one time. It seems to happen to different users at different times, but I am only going off heresay. The aspnet worker...
0
1525
by: James M via .NET 247 | last post by:
(I have 2x Front-end Web servers (Win2003 Ent IIS6.0), setup withNLB (single Affinity, also using SQLServer session state) thatare hosting a few .NET ASP web applications under the DefaultWebsite in IIS, and accessing via a Intranet LAN (this is notpublicly available). NETWEB1: NIC1 172.16.17.220 172.16.17.244 (NLB Virtual IP) NIC2 172.16.17.221 NETWEB2:
10
6644
by: Jeff Shepler | last post by:
This is probably not the right newsgroup for this, but this is the only one I read and there are a lot of smart people that "live" here. Please don't berate me if you think this should have been posted in another newsgroup. The web application I'm currently working on will (seemingly) randomly throw an exception when opening a database connection. Not always in the same place. Not always the same SqlConnection object. Not always the...
2
20847
by: AnalogKid17 | last post by:
Keywords: ASP.NET app with VS2005 running on Win2003 with IIS6, and SQL2000 on a WinXP Box I've betting the following for days... it's driving me insane: Server Error in '/' Application. Security Exception Description: The application attempted to perform an operation not
5
6135
by: chromis | last post by:
Hi there, I've recently been updating a site to use locking on application level variables, and I am trying to use a commonly used method which copies the application struct into the request scope. Application variables are then accessed in this manner Request.App.<Var>. To begin with I had a simple functioning login system inside a subdirectory named admin, this subdirectory had it's own application.cfm, I wasn't sure whether to duplicate...
3
5005
by: dihola | last post by:
Hi, I have a website running in IIS7 and it seems to be creating a new session for every request I make. The values I store in Session are lost with every request. This is the forms bit in my web.config: <authentication mode="Forms"> <forms name=".ReMaCRM" loginUrl="~/Login.aspx" defaultUrl="~/Default.aspx" cookieless="AutoDetect" domain="" timeout="10" protection="All" /> </authentication>
0
9617
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
10254
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10036
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,...
1
7451
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
6710
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();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2849
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.