Home > C#, WCF > WCF 4.0 REST tip: File-less activation

WCF 4.0 REST tip: File-less activation

With WCF 3.5, it was always a problem that the service URL’s of REST applications were ending with “.svc”. This was not very RESTfull. One of the new features in WCF 4.0 is the ability to register services for use in IIS without having to rely on “.svc” files. The syntax to configure this is simple:

<configuration>
	<system.serviceModel>
		<serviceHostingEnvironment>
			<serviceActivations>
				<add relativeAddress="Hello" service="MyNameSpace.HelloService" factory="MyNameSpace.MyServiceHostFactory"/>
			</serviceActivations>
		</serviceHostingEnvironment>
	</system.serviceModel>
</configuration>

The following configuration would allow IIS to host the service using the URL:

http//localhost:<portnumber>/<websitename>/Hello

The factory attribute is optional; it allows you to specify a ServiceHostFactory for your service.

Advertisements
Categories: C#, WCF
  1. Ai Apaec
    November 19, 2014 at 23:02

    Hi,nice post.
    But I have a question: ¿Why when Publish the WCF service (file-less) is copied the app_code folder with source file too?
    It’s not secure, we can’t have a source file in a published service. Or maybe i miss a configuration. Could you help me please?

    • pieterderycke
      January 20, 2015 at 11:40

      Could you better explain your issue.

  1. No trackbacks yet.

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

%d bloggers like this: