Development Tip: How to use Host Header with Development Server

by ilker Aksu 3. July 2009 08:17

If you are using “Asp.Net Development Server” One of the big problem of developing multiple web site at the same time is Development Server does not recognize and support Host Header. So you have to use different port for each web site. Problem with this solution is if you have hard coded links or templates pointing website you have to tweak code for testing and development.

Here is the solution; Use Fiddler

Let’s say we are developing ilkeraksu.com and hosting images at images.ilkeraksu.com at the same time and configured Visual Studio for using fix ports 9090 and 9091 respectively.

image


If you don’t know Fiddler please go to  http://fiddler2.com   and download this excellent tool.

Fiddler is a Web Debugging Proxy which logs all HTTP(S) traffic between your computer and the Internet. Fiddler allows you to inspect all HTTP(S) traffic, set breakpoints, and "fiddle" with incoming or outgoing data. Fiddler includes a powerful event-based scripting subsystem, and can be extended using any .NET language.

Fiddler is freeware and can debug traffic from virtually any application, including Internet Explorer, Mozilla Firefox, Opera, and thousands more.

For using Fiddler you may look at this post
http://www.west-wind.com/weblog/posts/596348.aspx

You can easily and happliy extend fiddler functionality.

Open Fiddler
Go to Rules->Customize Rules

image

It will open CustomeRules.js and there are several event functions for hooking.

Go to
Function static function OnBeforeRequest(oSession: Session)

and insert below lines for each web site you are developing


if (oSession.HostnameIs("ilkeraksu.com")) {
            oSession["x-overrideHost"] = "localhost:9090";
        }

        if (oSession.HostnameIs("images.ilkeraksu.com")) {
            oSession["x-overrideHost"] = "localhost:9091";
        }

If Host Header is ilkeraksu.com we are changing target host address and port.

Another advantage for this solution is you do not have to insert entry to host file to point ilkeraksu.com to 127.0.0.1

That’s all.
By the way, this is my first post ever :-)

 

 

kick it on DotNetKicks.com

 

Tags:

Comments

2/8/2010 2:48:06 PM #

outback steakhouse alice springs chicken

You come from a unique view ;)

outback steakhouse alice springs chicken United States | Reply

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen

ilker Aksu

Tag cloud