Click here to Skip to main content
Click here to Skip to main content

Simple HTTP Reverse Proxy with ASP.NET and IIS

By , 22 May 2004
 

Introduction

Sample Image - reverse-proxy.png

A reverse proxy is the same as a proxy except instead of delivering pages for internal users, it delivers them for external users. It can be used to take some load off web servers and provide an additional layer of protection. If you have a content server that has sensitive information that must remain secure, you can set up a proxy outside the firewall as a stand-in for your content server. When outside clients try to access the content server, they are sent to the proxy server instead. The real content resides on your content server, safely inside the firewall. The proxy server resides outside the firewall, and appears to the client to be the content server.

Where to use?

If you have an intranet with IP filtered security, you can offer the functionality of external consultation. You must just add the authentication system of your choice.

Functionality

This reverse proxy can run in two modes:

  • Mode 0: all web sites can be requested by clients with an URL like http://RevrseProxyURL/http//www.site.com/
  • Mode 1: only one web site can be requested. When the user requests the web application address, the proxy returns the content of this web site.

You can setup this mode in the web configuration file of you web application:

<appSettings>
    <!-- PROXY Mode
  0 : all web site can be requested by a client with 
      an url like <A href="http://reverseproxyurl/http//www.site.com/">http://ReverseProxyURL/http//www.site.com/</A>
  1 : Only on web site can be resuested by clients, \
      In this case Web Application uses RemoteWebSite variable 
      to deliver the content of the web site.
    -->
   <add key="ProxyMode" value="1" />
   <add key="RemoteWebSite" value="<A href="http://www.codeproject.com/">http://www.codeproject.com/</A>" />
</appSettings>

The code

Create an HttpHandler to intercept all requests:

using System;
using System.Configuration;
using System.Web;
using System.Net;
using System.Text;
using System.IO; 
namespace ReverseProxy
{
  /// <summary>
  /// Handler that intercept Client's request and deliver the web site
  /// </summary>

  public class ReverseProxy: IHttpHandler
  {
    /// <summary>
    /// Method calls when client request the server
    /// </summary>
    /// &;lt;param name="context">HTTP context for client</param>

    public void ProcessRequest(HttpContext context)
    {
      //read values from configuration 
      fileint proxyMode = 
        Convert.ToInt32(ConfigurationSettings.AppSettings["ProxyMode"]);
      string remoteWebSite = 
        ConfigurationSettings.AppSettings["RemoteWebSite"];
      string remoteUrl;
      if (proxyMode==0)
        remoteUrl= ParseURL(context.Request.Url.AbsoluteUri);
      //all site 
      acceptedelseremoteUrl= 
        context.Request.Url.AbsoluteUri.Replace("http://"+
        context.Request.Url.Host+
        context.Request.ApplicationPath,remoteWebSite);
      //only one site accepted
      //create the web request to get the remote stream
      HttpWebRequest request = 
        (HttpWebRequest)WebRequest.Create(remoteUrl);
      //TODO : you can add your own credentials system
      //request.Credentials = CredentialCache.DefaultCredentials;
      HttpWebResponse response;
      try
      {
        response = (HttpWebResponse)request.GetResponse ();
      }
      catch(System.Net.WebException we)
      {
        //remote url not found, send 404 to client 
        context.Response.StatusCode = 404;
        context.Response.StatusDescription = "Not Found";
        context.Response.Write("<h2>Page not found</h2>");
        context.Response.End();
        return;
      }
      Stream receiveStream = response.GetResponseStream();

      if ((response.ContentType.ToLower().IndexOf("html")>=0) 
        ||(response.ContentType.ToLower().IndexOf("javascript")>=0))
      {
        //this response is HTML Content, so we must parse it
        StreamReader readStream = 
          new StreamReader (receiveStream, Encoding.Default);
        Uri test = new Uri(remoteUrl);
        string content;
        if (proxyMode==0)
          content= ParseHtmlResponse(readStream.ReadToEnd(), 
            context.Request.ApplicationPath+"/http//"+test.Host);
        else
          content= ParseHtmlResponse(readStream.ReadToEnd(),
            context.Request.ApplicationPath);
        //write the updated HTML to the client
        context.Response.Write(content);
        //close streamsreadStream.Close();
        response.Close();
        context.Response.End();
      }
      else
      {
        //the response is not HTML 
        Contentbyte[] buff = new byte[1024];
        int bytes = 0;
        while( ( bytes = receiveStream.Read( buff, 0, 1024 ) ) > 0 )
        {
          //Write the stream directly to the client 
          context.Response.OutputStream.Write (buff, 0, bytes );
        }
        //close streams
        response.Close();
        context.Response.End();
      }
    }

    /// <summary>
    /// Get the remote URL to call
    /// </summary>
    /// <param name="url">URL get by client</param>
    /// <returns>Remote URL to return to the client</returns>

    public string ParseURL(string url)
    {
      if (url.IndexOf("http/")>=0)
      {
        string externalUrl=url.Substring(url.IndexOf("http/"));
        return externalUrl.Replace("http/","http://") ;
      }
      else
        return url;
    }

    /// <summary>
    /// Parse HTML response for update links and images sources
    /// </summary>
    /// <param name="html">HTML response</param>
    /// <param name="appPath">Path of application for replacement</param>
    /// <returns>HTML updated</returns>
    public string ParseHtmlResponse(string html,string appPath)
    {
      html=html.Replace("\"/","\""+appPath+"/");
      html=html.Replace("'/","'"+appPath+"/");
      html=html.Replace("=/","="+appPath+"/");
      return html;
    }
    ///
    /// Specifies whether this instance is reusable by other Http requests
    ///
    public bool IsReusable
    {
      get
      {
        return true;
      }
    }
  }
}

Configure the handler in web.config

You must add these lines in web.config file to redirect all user queries to the HTTPHandler:

<httpHandlers>
   <add verb="*" path="*" type="ReverseProxy.ReverseProxy, ReverseProxy" />
</httpHandlers>

Configure IIS

If you want to process a request with any file extension, then you need to change IIS to pass all requests through to the ASP.NET ISAPI extension. Add the HEAD, GET and POST verbs to all files with .* file extension and map those to the ASP.NET ISAPI extension - aspnet_isapi.dll (in your .NET framework directory). The complete range of mappings, includes the new .* mapping.

TODO's

Now, you can develop your own security system, based on form, Windows or passport authentication.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Vincent Brossier
Web Developer
France France
Member
Vincent Brossier is a software engineer from Paris, FRANCE, specializing in .Net.
Vincent is in charge of development of the Parisian university's Intranet, I take part in a nationnal project of numerical campus.
His role is to seek best technicals solutions to satisfy the 35000 users of this Intranet. Specialized in the development of distributed applications, vincent work primarily with technologies microsoft .NET (C#, ASP.NET, Webservices, SQLServer) even if he have also work with java technologies (Peer-to-peer sharing documents tool).
Vincent have also set up Open-Source solutions such as SPIP in nursery schools.
When he's not programming, he enjoys playing Guitar.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionNot Work in internetmemberDothanhhai2 Nov '12 - 9:57 
i run in clocal it run good, when i upload to host it error iis
QuestionWhen size of page to display too big, hangs briefly, renders incomplete pagememberJim Cross23 Nov '11 - 8:53 
Works fine until the size of the page to be rendered is too big (e.g. many records returned). The page will render partialy and then hang for a while (130 seconds; IE8 progress bar at 30%) and then finish rendering the page but the page is incomplete.
QuestionSpurious null character added to end of stream?memberSteven Hirschorn25 Aug '11 - 1:46 
Thanks for the code.
 
I've stripped out a lot of the code I don't need for my implementation but there is a problem with the output of the receiveStream output. The resources I am proxying are XML documents. The proxy returns them identically to the source server, but somehow appends a null character (0x00) to the end of the stream. I've run it through the debugger and it is not present in receiveStream so it is either by the context.Response.OutputStream.Write(buff, 0, bytes); line or the context.Response.End(); line.
 
I wouldn't worry about it if it didn't cause browsers to consider the XML doc malformed!
 
Does anyone know what introduces the stray character?
 
Thanks!
Steven
Questionreverse proxy and WCF-Servicememberwalter.anna24 Jan '10 - 1:56 
Hello,
 
i would like make reverse proxy with WCF-Service.
Can everybody help me?
 
Thanks.
 
Walter
Questionhow can i bypass the processrequest method?membervitiris4 Jan '10 - 18:11 
I'm using this proxy by the following:
 
google.mydomain.com will get the google.com website
yahoo.mydomain.com will get the yahoo.com website
and so on like that.
 
if i want to go to mydomain.com/login/default.aspx or some other page, how can I bypass the request and go directly to this page ignoring all of the reverseproxy code?
thanks
QuestionHow to set it up?membermaria_mir7 Jul '09 - 20:48 
I cannot figure out how to set up the demo project at my side. There are no installation instructions, only the global and web.config and a dll. How to start with it now?
AnswerRe: How to set it up?membermaria_mir12 Jul '09 - 22:18 
Following are its deployment instructions;
 
1. Create a new directory named Handler under the C:\Inetpub\Wwwroot directory.
2. Copy the bin directory with the dll (ReverseProxy dll) and the web.config in the Handler directory.
3. Follow these steps to mark the new Handler directory as a Web application:
4. Open Internet Services Manager.
o Right-click the Handler directory, and then click Properties.
o On the Directory tab, click Create.
o Follow these steps to create an application mapping for the handler. For this handler, create a mapping to the Aspnet_isapi.dll file for the .* extension.
o Right-click on the Handler Web application, and then click Properties.
o On the Directory tab, click Configuration.
o Click Add to add a new mapping.
o In the Executable text box, type the following path: Microsoft Windows 2000:
 C:\WINNT\Microsoft.NET\Framework\<version#>\Aspnet_isapi.dll
o Microsoft Windows XP:
 C:\WINDOWS\Microsoft.NET\Framework\<version#>\Aspnet_isapi.dll
o In the Extension text box, type .*
o Make sure that the Check that file exists check box is cleared
o Double click the path textbox if OK button is not enabled; and then click OK to close the Add/Edit Application Extension Mapping dialog box.
o Click OK to close the Application Configuration and the Handler Properties dialog boxes.
o Close Internet Services Manager.
 
Now browse to http://localhost/Handler/http//www.google.com – for mode 0
And http://localhost/Handler/ - for mode 1
AnswerRe: How to set it up?membereric_ruck4 Aug '11 - 5:44 
You can also copy the ReverseProxy.cs into a folder called App_Code within your web application. In your web.config file, when you add the httpHandler, set the type to "ReverseProxy.ReverseProxy" (leave out the text past the comma).
GeneralSome changesmemberrickleb21 Mar '09 - 6:16 
I used this code to set up another IIS 6 website in parallel with my public site. This is a secure (SSL) site. So I wanted to use https externally to access internal http servers (Nagios running on Apache on Linux). Here is a summary of the changes that I made. First, note that I did not test the "all sites" proxy mode, just the individual site mode.
 
So my IIS 6 setup looks like this:
 
Default site (my primary HTTPS site)
nagios1 (my first nagios server)
nagios2 (my second nagios server)
 
nagios1 and nagios2 each have the ReverseProxy application installed in the root. On IIS 5 & 6, if you want to map all mime types to the ihttphandler, you must do it for the entire site. That is why I didn't just use a virtual directory. IIS 7 removes this restraint.
 
The first change was to this section:
 
 string remoteUrl;
 if (proxyMode==0)
    remoteUrl= ParseURL(context.Request.Url.AbsoluteUri); //all site accepted
 else
   remoteUrl= context.Request.Url.AbsoluteUri.Replace("http://"+
         context.Request.Url.Host+context.Request.ApplicationPath,remoteWebSite); 
 

There were 2 issues. The first was that "http://" was hard coded. Wouldn't work for https. In my case, the external site was https and internally it was http. After the following changes, this wasn't an issue. The second issue was that sometimes "proxy.aspx" was in the URL, sometimes not. I put some code in to check for this as well:
 
 string remoteUrl;
 
 string sProtocol = context.Request.Url.Scheme + "://" + 
           context.Request.Url.Host +  context.Request.ApplicationPath;
 remoteUrl = context.Request.Url.AbsoluteUri.Replace(sProtocol, remoteWebSite); //only one site accepted
 int iLength = remoteUrl.LastIndexOf("proxy.aspx");
 if (iLength > 0)
    remoteUrl = remoteUrl.Substring(0, iLength);
 
A second issue was that on any error, "404" was returned, which made it very hard to determine what the real back end error was. I changed the exception block to pass along the backend error with a description:
 
Original code:
 
 catch(System.Net.WebException we)
 {
 //remote url not found, send 404 to client 
	context.Response.StatusCode = 404;
	context.Response.StatusDescription = "Not Found";
	context.Response.Write("<h2>Page not found</h2>");
	context.Response.End();
	return;
 }
 
New code:
 catch(System.Net.WebException we)
 {
	int		iStatus;
	string	sStatus;
	//remote url not found, send status to client 
	sStatus = we.ToString();
	int iIndex = we.ToString().IndexOf('(');
	iStatus = 491; // Our own error code if theirs is invalid - unlikely
	if (iIndex != -1)
            iStatus = Convert.ToInt32(we.ToString().Substring(++iIndex, 3));
	context.Response.StatusCode = iStatus;
	context.Response.StatusDescription = we.Message;
	context.Response.Write("<h2>From ReverseProxy - " + we.Message + 
            "</h2><br><center><h3><br>" + we.Data + "<br>URL: " +
                   we.Response.ResponseUri + "</br></br></h3></center>");
	context.Response.End();
	return;
 }</br>
 

Lastly, the remapping of the links didn't work if the application was in the web site's root directory. This was because the replacement string was basically a single '/'. In this case, the browser would not have the correct relative path or the absolute path.
 
The solution was easy. Pass the absolute path. So
 
content= ParseHtmlResponse(readStream.ReadToEnd(),context.Request.ApplicationPath);
 
becomes
 
content = ParseHtmlResponse(readStream.ReadToEnd(), sProtocol);
 
Note that "sProtocol" was calculated above.
 
And finally, change ParseHtmlResponse from
 
 public string ParseHtmlResponse(string html,string appPath)
 {
	html=html.Replace("\"/","\""+appPath+"/");
	html=html.Replace("'/","'"+appPath+"/");
	html=html.Replace("=/","="+appPath+"/"); 
	return html;
 }
 
to
 
 public string ParseHtmlResponse(string html,string appPath)
 {
	html = html.Replace("\"/", "\"" + appPath);
	html = html.Replace("'/", "'" + appPath);
	html = html.Replace("=/", "=" + appPath); 
	return html;
 }
 
Since the trailing backslash is already included in sProtocol.
 
These changes did not break the way the code worked originally, but they do make it more robust and work in more environments.
 
Finally, to save others a lot of heartache, here is a link to an article on how to create a server certificate that can be shared by different sites on the same machine using SSL host headers. This is non-obvious, and you can't have multiple SSL sites without it.
 
http://thelazyadmin.com/blogs/thelazyadmin/archive/2006/06/16/IIS-6.0-and-SSL-Host-Headers.aspx[^]
 
Also, remember that the "common name" for each site must be in DNS so IIS knows which site to direct the request to.
 
Now you can host multiple servers from a single IIS servers, using https externally and http internally ig you desire.
 
Hope this helps others.
Rick Bross
 
Hope this helps others.
GeneralRe: Some changesmemberMunirS30 Aug '09 - 2:04 
In regards to remapping fo URLS in ParseHTML routine, why would you change all paths to absolutepaths?
 
Aren't you supposed to leave everything relative to the address on the browser (ie context URL)?
 
If you point the links to an absolute value, you risk changing the address on the address bar.
 
Isn't reverse proxy supposed to act as if it supplying the content from the address that the user types in, ie on the browser??
 
Those who try and those who fry!

GeneralPour InfosmemberMember 210144124 Sep '08 - 3:34 
Salut Vincent
Je t'explique ma problematique:
J'ai un site Web classique les internautes clique sur un lien qui redirige vers une serveur Web situe dans un dmz (la ou j'ai installe ta solution) nesuite le resverse proxy redirige vers des pages html situe sur un serveur dans le lan. Je voudrait implemente une securite au niveau du firewall
mais quand je passe par ta solution si je regarde la variable remote address elle me sort toujours celle de l'internaute et non celle de ton proxy comment faire pour avoir la remote adress correspondant à la machine hebergeant dans la dmz ton proxy
merci à toi
 
marc.casadaban@gpi-info.net
GeneralInstallation InstructionsmemberChris Spencer15 Jul '08 - 3:17 
Where is the install documentation? The only files in the ZIP are the Web.config, Global.asax, and the DLL. No readme.txt, install.txt, or anything.
GeneralRegarding Host Headermemberpmselvan_20005 Jul '08 - 8:29 
My Application requires that the reverse proxy server does not change the host header. It must be forwarded fully transparently from the browser to the server. This is necessary to be able to differentiate between Internet requests and intranet requests.
 
For example, Apache reverse proxy (mod_proxy) has the configuration option 'ProxyPreserveHost' to support this feature.
 
This reverse proxy support this above feature. Pls reply as early. Thanks in advance.
 
Paul
GeneralRe: Regarding Host HeadermemberMunirS30 Aug '09 - 1:56 
I think Paul, you will need to capture each header in the request object and pass them on. This is in order to keep the actual request the same as it was sent from the client.
 
No one is born a .net developer, you become one!

GeneralRe: Regarding Host HeadermemberStimphy21 Dec '09 - 15:03 
That doesnt seem work for ASP.NET pages. The httpWebResponse object does not appear to allow the programmer add asp.net response headers. I have tried and it simply errors.
 
Regaurds,
Stimphy

GeneralErrormemberVJLaks16 Jun '08 - 20:39 
I got the output, But once i try to navigate from that page I get an error for example: If i call google.com from proxy. I get an error while searching a page from the proxy. What shall I do for that.
GeneralDerivative WorkmemberPaul Johnston4 May '08 - 4:35 
Hi,
 
Interesting code, simple and to the point, thanks for posting it. I've had a need for a slightly more featureful reverse proxy script, mostly that passes headers correctly in both directions. I've coded this up, taking inspiration from your script and another one that used to be online but has disappeared. It's at http://code.google.com/p/iisproxy/[^] if you want to take a look. Hope this is ok by you,
 
Paul
GeneralErrorsmemberhanisacsouka13 Apr '08 - 2:32 
I got the following errors in Event Viewer
 
Event Type: Error
Event Source: W3SVC-WP
Event Category: None
Event ID: 2214
Date: 4/13/2008
Time: 2:18:20 PM
User: N/A
Computer: SERVER
Description:
The HTTP Filter DLL C:\Inetpub\wwwroot\test\bin\ReverseProxy.dll failed to load. The data is the error.
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Data:
0000: 7f 00 00 00 ...
 

Event Type: Error
Event Source: W3SVC-WP
Event Category: None
Event ID: 2268
Date: 4/13/2008
Time: 2:18:20 PM
User: N/A
Computer: SERVER
Description:
Could not load all ISAPI filters for site/service. Therefore startup aborted.
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
Data:
0000: 7f 00 00 00 ...
Generalhttp://www.site.com:8080/memberhanisacsouka12 Apr '08 - 8:05 
I need to use your application to open a website on port 8080
GeneralIIS 7.0memberbrice2nice13 Nov '07 - 10:50 
Hi,
 
I try it on IIS 7.0 but I don't know how configure the server. I have made the mapping ISAPI but I have the Error HTTP 403.14 - Forbidden.
 
Have you got any solution ?
 
chears.
 

Generalenabling file downloadmembertarak4v5 Sep '07 - 19:49 
what if Application sends;P file from server side??
 
can we enable file passing to the client browser via this proxy...(indirect file LINKING) such as .rar .zip .pdf .exe..
 
I tried with some of the doc file but as there is stream reader it shows doc file content with some of the garbage value in the browser..
 
Hope to have your reply soon..
 

Thanks in advance...
 
TARAK
GeneralVery usefull for me. View my project for download files from rapidshare.com based on this sample [modified]memberW.M. Spon29 Jun '07 - 22:54 
Very usefull for me. View my project for download files from rapidshare.com based on this sample http://www.xd24.ru/start.aspx
Absolutly free download files from rapidshare.com and rapidshare.de via asp.net proxy! No wait! Thanks.

GeneralI couldnt get it workmemberjeanmoura12 Apr '07 - 5:01 
Sorry Vincent, but I couldnt get the reverse proxy work. I tried install the demo in my IIS but it didnt work.
I have IIS 6 and I couldnt configure IIS, that file extension you mentioned.
What about the reverseproxy.dll? Should I configure it anywhere to get it run?
Should I create an virtual directory to this app?
Please help
 
best regards from Brazil
 
Jean
Questionimage path doesnt workmembernolovelust5 Apr '07 - 10:45 
hi i am not sur eif this article watched but proxy does not give correct path for images.
 
for example if you browse google
 

http://localhost/http/google.com
 
images links becomes
 
//http//google.com/images/nav_logo2.png
 
all internal links becomes
 
//http//google.com/....
 
any ideas how to fix it?
AnswerRe: image path doesnt workmemberMySuperName11 Jan '09 - 21:51 
guys!
any ideas how to fix it?
GeneralBisuitsmembersafari7501223 Mar '07 - 4:52 
Salut Vincent,
 
Je vais essayer ton reverse proxy sur une machine Windows 2000 server a partir de lundi, mais j'ai une question prealable: Est-ce que ton proxy forwarde des cookies? Ou faudrait-il plus pour cela?
 
Merci en avance,
 
Felix
GeneralHTTPS supportmemberDeason21 Nov '06 - 18:11 
Just for information's sake. If you'd like this to support https in mode 1 then simply update the line else statement for mode 1 to be this:
 
remoteUrl = context.Request.Url.AbsoluteUri.Replace(context.Request.Url.Scheme + "://" + context.Request.Url.Host + context.Request.ApplicationPath, remoteWebSite); //only one site accepted
GeneralReverse proxy apache and IISmemberharinath28 Oct '06 - 2:29 
Hi,
 
Apache does reverse proxy with just simple configuration. Is this feature not available on IIS?
 
I see this article explaining the HTTPHandler solution for rverse proxy option.
 
Let me know if you have any information

 
Thanks
 
Harinath
India

General401 errormembermredlon14 Sep '06 - 2:18 
I tried to redirect to another virtual directory but kept getting file not found even though it existed. I commented out the 404 code and found that the problem was due to error 401 not authorized. Any ideas?
GeneralReverse proxy with .css and .aspx files.memberyashchawhan3 Aug '06 - 19:40 
While i am working with the reverse proxy using the downloaded project,i make the changes in the source of the website so that it uses the reverse proxy to get the response.But it is not working with the .css files.i.e,it is not getting these files.Kindly help please....Thanks..
 
Yashpal A Chawhan
GeneralRe: Reverse proxy with .css and .aspx files.memberMunirS30 Aug '09 - 1:39 
Did anyone manage to answer this?
 
I guess my answer would be to make sure that the css files + js files are pointing to the correct location and to a location that is accessible from the client. Therefore url mapping on the response content maybe necessary. Please anyone?
Thanks for an execllent article!
 
Those who try and those who fry!

GeneralRe: Reverse proxy with .css and .aspx files.memberStimphy21 Dec '09 - 15:06 
I tried using this code, it seems to work with html pages. But when you need to work with ASPX pages that have sessions and cookies, it fails. I dont konw if its possible to make it work at all with these types of pages, however I am working to resolve the issue. If I get it to work, I will post how. If someoneelse has already solved this issue, please reply.
 
Regaurds,
Stimphy

QuestionReverse Proxymemberyashchawhan24 Jul '06 - 2:45 
I am using the downloaded sample in Mode 1,Then for example when the RemoteWebsite is www.iopsis.com. it shows the contents without images.And then when i click on sublinks like contact us or Services it gives a error saying that page not found.And here while the URL in the begining is http://localhost/ReverseProxy and then when i click on sublink the name of the project ReverseProxy goes and the URL of the sublink is appended to the localhost.Kidly help me to solve this problem.Thanks in advance.
 

GeneralTrailing slashmembereggsovereasy17 Apr '06 - 3:49 
I have site1 on server1 and site2 on server2. When a user views site2 I want it to to appear as http://site1/someFolder in the address, exactly what this program should do (and does on my dev box). However, on the production machines if I type in http://site1/someFolder I get the login dialog box, but if I type in http://site1/someFolder/ it gets proxied perfectly. So, I modified the ParseURL method so that it adds the trailing slash, this didn't change anything. So obviously there is some problem with the configuration in IIS on server1. I have a directory set up as a site in IIS for site1. Within site1 I have a virtual folder that points to the directory where I have placed the Reverse Proxy code. site2 is set up as a site in IIS on server2 if that matters.
 
Any suggestions?
GeneralRe: Trailing slashmemberRitchie Carroll13 Jun '06 - 10:11 
I have a modified version of this code we use for simple reverse proxies which has the same issue - no trailing slash and you get:
 
Server Error in '/' Application.
--------------------------------------------------------------------------------
 
Access is denied.
Description: An error occurred while accessing the resources required to serve this request. You might not have permission to view the requested resources.
 
Error message 401.3: You do not have permission to view this directory or page using the credentials you supplied (access denied due to ACLs). Ask the Web server's administrator to give you access to 'c:\inetpub\wwwroot\testapp'.
 

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version
 
Wish I had a solution...
AnswerRe: Trailing slashmemberUL-Tomten16 Jan '08 - 7:54 
Ritchie Carroll wrote:
no trailing slash and you get

Could it be this? http://support.microsoft.com/kb/216493[^]
Generaljavascript and postbackmembertomanyquestions19 Mar '06 - 23:30 
Hello and congratulations for the article,
I have been trying to use it in a page that contains a gridview and although it behaves as expected when i click in the select button it fails giving me a message :
Microsoft JScript runtime error: Object expected
and when i debug it it says:__doPostBack('_ctl0$ContentPlaceHolder1$grdServices','Select$0')
any idea what i am doing wrong?
 
thanks in advanse,
Akis
GeneralCaching imagesmemberpratz1722 Feb '06 - 19:03 
I have the following setup
 
Client/User <-----> Reverse Proxy on DMZ <-----> IIS/Web application
 
Any ideas on how to cache images on the reverse proxy to improve performance? I tried page level caching on the aspx page but it did not help. The reverseproxy spends a lot of time downloading images from the remote website in the form of http requests. The target page uses Infragistics tab controls which use a lot of images(gifs) to render the controls.
 
If there is some way I could cache the images on the Reverse proxy, it would drastically improve performance.
 
Would appreciate any help on this. Thanks.
Question..what about conversion to VS 2005??membernikolair16 Nov '05 - 4:27 
I have tried this, and after the conversion it claims that is not an allowed entry in web.config. Any ideas what to do???
GeneralPass values from .aspx page to remote URL that contains an asp pagesussAnonymous18 Oct '05 - 20:10 
I have an ASP.NET application in which i just want to pass the details from .aspx page to some remote URL where the remote URL end contains asp form. For e.g my website is www.knowyourday.com and have a CustomerDetails.aspx page from which i just need to pass the some values from it to remote URL http://goldshield.astroastro.com/adduser.asp. ;
So how to implement the same. I had used Server.Transfer() but it always give me error that virtual path required. PLEASE HELP ME AS SOON AS POSSIBLE.....

GeneralW2k3 / IIS 6memberDavid Llamas15 Jul '05 - 17:44 

Have you tried this software in the scenario Windows 2003 + IIS 6?
 

 
David
AnswerRe: W2k3 / IIS 6membertarak4v9 Sep '07 - 22:10 
hey.... friends ..!!
 
It's Simple as your did it in the Win XP..
 
just instead of adding isapi.dll for --.*
 
you need to specify the same thing in the wildcard file Processing....
 
rest it will take care...
 
Enjoy....!!!
 

Tarak..
GeneralAccess Denied...memberRitchie Carroll28 Jun '05 - 4:03 
I got this to sucessfully work in my test environment, got cookies working, got posts working - but when I deploy this code I immediately get a login prompt - even when enter my user credentials I get "Access is denied.". I added some logging and this is not even getting to the .NET http handler. I've added all kinds of rights to my deployment folder to no avail...
 
Any thoughts??
 
Thanks,
Ritchie
GeneralRe: Access Denied...memberRitchie Carroll29 Jun '05 - 10:59 
I figured it out - I had referenced another assembly in my reverse proxy assembly that ended up in the bin folder with the reverse proxy assembly - removing reference to this solved the problem for whatever reason... Weird...

GeneralUnit Testing ReverseProxymemberbtakita25 May '05 - 11:49 
Hello,
 
Do you have a unit test for ReverseProxy?

 
Sincerely,
Brian Takita
GeneralCant see imagesmemberpratz1728 Apr '05 - 3:08 
Good Article Vincent.
 
One problem - If I set it up to open www.codeproject.com, or any other website, It does not show the images.
 
Did anyone else face this problem? I saw a thread about content-type. Do I need to tweak the code so images diplay correctly? Currently I see only image placeholders on the web page.
 
Thanks.
 
Pratz
GeneralRe: Cant see imagesmemberRitchie Carroll28 Jun '05 - 3:57 
Try increasing the default connection limit - it's set to 2 by default - not enough for a web page with many graphics:
 
ServicePointManager.DefaultConnectionLimit = 100
 
Hope that helps!
Ritchie
JokeRe: Cant see imagesmemberUL-Tomten16 Jan '08 - 7:56 
The "simultaneous connections per IP" setting in machine.config probably also needs to be changed.
http://msdn2.microsoft.com/en-us/library/system.net.configuration.connectionmanagementelement.maxconnection.aspx[^]
GeneralAdding Session HandlingmemberDavid Osbourn10 Mar '05 - 6:01 
I've extended your code to fit my needs and it is all working well. My problem is that I can't seem to add any values to the Session Object. If I try and retrieve the session from the context, which gets passed in 'public void ProcessRequest(HttpContext context)', all I get is a null object, e.g.
 
HttpSessionState sess; sess = context.Session;

 
It compiles, but sess always equals null.
 

This is most frustrating as everything else is working really well!
GeneralRe: Adding Session HandlingmemberVincent Brossier10 Mar '05 - 8:51 
The HttpHandler must to implement IRequiresSessionState. It's a marker interface which tells SessionStateModule that the handler uses session

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 23 May 2004
Article Copyright 2004 by Vincent Brossier
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid