Home | mikebedan.net | Click here to send an email to the editor of this weblog. Updated: 6/1/2003; 7:54:08 PM. 

  web_dev
Web/Internet Development Information and News

>
Thursday, March 13, 2003 daily link


> HttpHandlers and the IIS Metabase.

Our team has recently consolidated a bunch of intranet sites housed on various team members' machines into subwebs on a larger server.  I had been hosting one of the sites from my office, and needed a way to redirect all hyperlinks to that particular subweb to a new subweb without affecting the rest of the sites on the machine.  ASP.NET provides a rather simple way of doing this:

using System.Web;

namespace Forward {
  public class Forwarder : IHttpHandler
    {

    public Forwarder(){}

    public void ProcessRequest(HttpContext context)
      {

      string subWeb = "http://mymachine/subweb";
      string oldWeb = "http://newmachine/newsubweb";

      HttpRequest request = context.Request;
      HttpResponse response = context.Response;
     
      string newUrl = request.Url.AbsoluteUri.Replace(subWeb,newWeb);
      response.Redirect(newUrl);
      }

    public bool IsReusable
      {
      get { return false; }
      }
    }
  }

compiled as forward.dll and placed in the subweb's bin/ directory, with the following added to the Web.config:

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

Funny enough, this only worked for paths like http://mymachine/subweb/foo.aspx, since paths like http://mymachine/subweb/foo.htm were routed directly to the filesystem by IIS and bypassed ASP.NET.  I remembered having this problem before, when .NET was still in development, and the trick was to associate the "*" file extension with ASP.NET in the script map.  Too bad IIS no longer stores the script map in the registry where it's easy to mess with.

A bit of searching and I found:

http://support.microsoft.com/default.aspx?scid=KB;en-us;q232068#3

I just had to use MetaEdit to find LM/W3SVC/1/ROOT/ScriptMaps and add:

*,C:WINDOWSMicrosoft.NETFrameworkv1.2.x86dbgaspnet_isapi.dll,1

and everything is working great now.

 

 

[Better Living Through Software]
7:41:51 AM  permalink    comment [] - See Also:  web_dev 



 

March 2003
Sun Mon Tue Wed Thu Fri Sat
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Feb   Apr

testRoll
wedgeInfo
wedgeOther Webs

Subscribe to "web_dev" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.
Click here to visit the Radio UserLand website.



Copyright 2003 © Mike Bedan.
Last update: 6/1/2003; 7:54:08 PM.