As is usually the case, posting the issue publicly helps me find the solution faster; quite the odd phenomenon. :)
Anyway, I figured out how to get the WCF application to work properly as an IIS application under mojoPortal.
1. In IIS Manager, create a new Application under your mojoPortal website. Right-click -> Add Application. Select the folder of your WCF project. I used 'api' for the Application (virtual folder) name.
2. Here's the test WCF Service class:
namespace WcfTest
{
[ServiceContract]
public interface ITestRest
{
[OperationContract]
[WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
string TestGetNoParameters();
[OperationContract]
[WebInvoke(Method = "*", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
string TestInvokeAnyMethodNoParameters();
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
string TestPostNoParameters();
}
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public class TestRestService : ITestRest
{
public string TestGetNoParameters()
{
return "success";
}
public string TestInvokeAnyMethodNoParameters()
{
return "success";
}
public string TestPostNoParameters()
{
return "success";
}
}
}
3. Here's the web.config of the WCF project:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="TestRestService/TestGetNoParameters" helpEnabled="true" automaticFormatSelectionEnabled="false" defaultOutgoingResponseFormat ="Json" crossDomainScriptAccessEnabled="true"/>
<standardEndpoint name="TestRestService/TestInvokeAnyMethodNoParameters" helpEnabled="true" automaticFormatSelectionEnabled="false" defaultOutgoingResponseFormat ="Json" crossDomainScriptAccessEnabled="true"/>
<standardEndpoint name="TestRestService/TestPostNoParameters" helpEnabled="true" automaticFormatSelectionEnabled="false" defaultOutgoingResponseFormat ="Json" crossDomainScriptAccessEnabled="true"/>
</webHttpEndpoint>
</standardEndpoints>
</system.serviceModel>
</configuration>
4. This is what the global.asax.cs should look like:
namespace WcfTest
{
public class Global : HttpApplication
{
void Application_Start(object sender, EventArgs e)
{
RegisterRoutes();
}
private void RegisterRoutes()
{
RouteTable.Routes.Add(new ServiceRoute("TestRestService", new WebServiceHostFactory(), typeof(TestRestService)));
}
}
}
5. Navigate to the TestGetNoParameters method and you should get 'success'.
http://www.mymojosite.com/api/TestRestService/TestGetNoParameters
Hopefully this helps somebody out; most likely me when I forget in 2 months. :)