locked
HttpHandler / Http Module (Can it be done). RRS feed

  • Question

  • User-526849425 posted
     I have a site that currently has a URL like www.mysite.com\{appname}

    I am migrating to a new server and want to change the URL to follow our new standard {appname}.mysite.com

    The site is for serving up web services and our current customers must not see any outages, or need to make any changes to continue to work.  I am thinking I can write httpHandler or HttpModule and changed the www.mysite.com\{appname} to {appname}.mysite.com.  Can this be done this way?  If so, is this the best way to handle this situation. 

    Any feedback will be appreciated.

    Tuesday, August 7, 2007 4:26 PM

All replies

  • User1001868398 posted

    No you cannot do that as that request is handled by DNS, so you do not receive the request using the DNS has resolved the IP. Sorry.

    You can change the configuration to send all subdomain to a website, but that's another place. You can post it to http://iis.net

    Tuesday, August 7, 2007 4:30 PM
  • User-225114762 posted

    As a side note for other readers who may consider making a similar decision, I might mention that it's not always a smart move to use {appname}.mysite.com as a standard instead of www.mysite.com\{appname}.

    This is for several reasons, but the one must directly felt in the wallet is the fact that if you want to run SSL, i.e. access the site via HTTPS, you'll have to purchase a separate certificate per application, or get a much more expensive wild-card certificate.

    Another reason is of course what you've just discovered - you now have three separate infrastructures that must be in agreement of things: The DNS servers (this is often adminstratively complicated to update, you have to go through your own or your ISP's IT-department), the web server and the application.

    What you actually can do if you really want to provide transparent access via the old URL, is to write a small proxy application that answers at the old URL. Search CodeProject for example for "reverse proxy". It's probably not worth the effort though, and in the end you need to have your customers change the URL at their end anyway.

    Wednesday, August 8, 2007 1:14 AM
  • User-526849425 posted

     Al

    I know that DNS resolves the URL and both URL's would resolve to the same IP, thus going to the same site.  What I want to do is change the URL using an HttpHandler or Http Module on the front end before to change the mysite.com\{appname} to {appname}.mysite.com.  I do remember attending a seminar where something similar was done with an httpHandler, but do not remember how it was done.

    Wednesday, August 8, 2007 2:12 AM
  • User-225114762 posted

    I think you're referring to the technique often called URL Rewriting. This is often done via a HttpModule. Search for "url rewrite" and you'll find several free and open source packages that implement this in various degrees of ambition.

    On the other hand - if your web service works as it should, it should be rather agnostic to where it's root resides, and should operate the same regardless if it is reached via http://appname.mysite.com/ or via http://www.mysite.com/appname/ . Why do you need to simulate access via the old URL? Am I missing something?

    Wednesday, August 8, 2007 2:20 AM
  • User-526849425 posted

     We use application caching and this is on a web farm.  When the user updates any data in the cache I have code that calls a web method on each each individual server to refresh that servers caches.  Therefore, I cannot have 2 sites mysite.com\{appname} and {appname}.mysite.com since updating the cache using 1 URL would not update the cache for the other URL since they are the different applications/sites. That is why I need the application to see everyone coming to {appname}.mysite.com not matter what URL the access the site from.  That way the application cache will correctly be refreshed on all servers for the single application/site.

    Saturday, August 11, 2007 1:43 AM