Reputation: 14409
I have a WCF service hosted on my website A. And I have another site B, that redirects all requests to my site A using IIS URL rewriting. However, site B doesn't handle any requests to .svc files, returns 404 not found. Any idea how to make it working?
UPD redirection config is like this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect" stopProcessing="true">
<match url=".*" />
<action type="Rewrite" url="http://localhost/site_A/{R:0}" logRewrittenUrl="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I've found that there is no any requests to .svc files in the IIS logs of website A (!). It doesn't redirect these requests to site A. However, when I request .htm files from the site B, it redirects them to site A correctly.
Upvotes: 4
Views: 6706
Reputation: 424
If you still need the server to handle other regular traffic including some services, one option is to create an app pool just for redirection that has no managed code.
Example:
Say that you want everything to http://Websites/WcfServices to redirect somewhere else.
First, make sure that URL Rewrite and ARR are installed and setup your reverse proxy. (Note that you can change the inbound rewrite rule to point to a specific path as well, not just another server)
Create an app Pool for WcfServices with No Managed Code:
Make sure that WcfServices uses the new app pool:
At this point, WCF cannot intercept calls to something like http://Websites/WcfService/CustomerDetails.svc since no .net modules can be loaded. All traffic will be routed to the internal server set in the reverse proxy.
Upvotes: 1
Reputation: 8775
Even if you were to add a .SVC handler in IIS and redirect it in the same manner as you do the .HTM requests, the redirection will not preserve the body of the message. So a request to a service method on SiteB will not necessarily be the same as a service method call on SiteA - this depends on your configuration, whether it is exposed RESTfully, and what your bindings are.
You can have a look at WCF 4.0's Routing feature. This requires you to write certain logic to recognize a call and have it call another endpoint.
A 'cruder' solution is to simply have SiteB host a proxy service which simply accepts incoming requests and calls SiteA's equivalent service, gets the result and returns it to the caller.
Upvotes: 1
Reputation: 8116
I'm not sure, but as far as I remember it may happen if you don't have http handler for .svc on web site B
Upvotes: 1