I created a WCF web service that I wanted to host on a web site and domain different from my main TheThoughtfulCoder.com domain. The problem is AJAX calls can not be made to different domain names, even if they are sub domains.
I'm using dasBlog to host my main blog site and I don't want to put my web services
in the same project. I want to keep my web services completely separate. So making
a call from thethoughtfulcoder.com to a web service hosted on the domain services.thethoughtfulcoder.com
can not be done. Hmmm...bummer!
I found a way to make this work in a straight forward manner. At least I think it
is :-)
IIS 7 has an addon called Application Request Routing which allows IIS to proxy
calls to another web site to satisfy cross domain rewrite rules. Ah ha! Now I can
rewrite a reqeust to a service on my main site and on the web server rewrite it
to my services subdomain. To set this up I followed the steps listed below.
The above rewrite configuration will generate the following XML in the web.config
file:
<rule name="TTC-Service Rewrite" stopprocessing="true">
<match url="^ttcservice/(.*)$">
<conditions logicalgrouping="MatchAll">
<action type="Rewrite" url="http://services.thethoughtfulcoder.com/TTCService.svc/{R:1}">
</action>
</conditions>
</match>
</rule>
If you have any questions or need any clarification please let me know and I'll try to clarify the steps. Of course there are likely many other ways to accomplish making cross domain AJAX calls, but this solution might be good enough :-)
Next entry: God of War – The best game ever made?
Previous Entry: Missing .svc path from IIS 7 handler mappings
Latest entries:
Create absolute URLs using ASP.NET MVC
Comments
My Links
Tags
Follow me
About
Powered by FoxBlog
Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2011, Nathan Fox