Fileless activation without svc extension (sort of)

Hosting WCF services in Windows Azure is easy:

  1. create service contract and implementation,
  2. add serviceactivation to web.config of the Role you’re hosting the service in.
...
  <system.serviceModel>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" >
      <serviceActivations>
        <add relativeAddress="calculator.svc" 
             service="CalculatorServiceImplementation"/>
      </serviceActivations>
    </serviceHostingEnvironment>
  </system.serviceModel>
...

The serviceactivation needs a registered extension (svc) to be activated. When you want to do this without an extension use the IIS Url Rewrite extension and add the rewrite of the url without the .svc to the web.config. This extension is default available and activated in Windows Azure.

...
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <rewrite>
      <rules>
        <rule name="Calculator Rule" stopProcessing="true">
          <!-- Match Calculator on the end of the url -->
          <match url="Calculator" />
          <!-- Redirect to the .svc url where the service will be activated -->
          <action type="Rewrite" url="Calculator.svc" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
...

The .svc url is still available and is actually used to activate the service. But that is what the sort of in the title is for 😉

About erictummers

My work as a recruited developer changes almost every month. I like challenges and sharing the solutions with others. On my blog I’ll mostly post about my work, but expect an occasional home project, productivity tip and tooling review.
This entry was posted in Development and tagged , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s