WCF Rest Web Service Returning Blank Page

Discussion in 'ASP.NET WebServices' started by ryandb2, Oct 30, 2011.

  1. I'm having some issues getting a WCF Rest web service I created working with DiscountASP. The goal is to call a web service located at /thelandsocial/map and return JSON. This is all working great in the local debug instance, but when placed on the discountasp servers I get a blank page returned with no JSON.

    Below is my web.config
    Code:
    <?xml version="1.0"?>
    <configuration>
        <system.webServer>
         <httpErrors errorMode="Detailed" existingResponse="PassThrough" />
         <asp scriptErrorSentToBrowser="true"/>
          <security>
            <authentication>
             <anonymousAuthentication enabled="false"/>
             <basicAuthentication enabled="false"/>
            </authentication>
          </security>
        </system.webServer>
        <system.web>
            <customErrors mode="Off" />
            <compilation debug="true" />
            <authentication mode="None"/>
        </system.web>
        <system.serviceModel>
          <bindings>
            <webHttpBinding>
              <binding name="webHttpBindingWithJson" />
            </webHttpBinding>
          </bindings>
          <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
          <standardEndpoints>
            <webScriptEndpoint>
              <standardEndpoint name="" crossDomainScriptAccessEnabled="true"/>
            </webScriptEndpoint>
            <webHttpEndpoint>
              <standardEndpoint name="theLandSocial" helpEnabled="false" automaticFormatSelectionEnabled="false" defaultOutgoingResponseFormat ="Json">
              </standardEndpoint>
            </webHttpEndpoint>
          </standardEndpoints>
        </system.serviceModel>
    </configuration>
    
    on my local machine a call to localhost:57566/theLandSocial/map returns my test json from my database hosted at discountasp:
    Code:
    [{"Created":"\/Date(1315130340000-0600)\/","GeoLat":33.81136,"GeoLong":-117.92,"GeoStatus":"geoc","ID":4,"UserName":"Other","UserStatus":"c"},{"Created":"\/Date(1315130040000-0600)\/","GeoLat":30,"GeoLong":33,"GeoStatus":"geod","ID":5,"UserName":"Third","UserStatus":"d"},{"Created":"\/Date(1315233660000-0600)\/","GeoLat":30,"GeoLong":33,"GeoStatus":"geof","ID":6,"UserName":"Ryan","UserStatus":"e"}]
    
    The global.ascx is also pretty straightforward:
    Code:
    namespace ThePocketofResistance.theMapSocialServices
    {
        public class Global : System.Web.HttpApplication
        {
    
            protected void Application_Start(object sender, EventArgs e)
            {
                RegisterRoutes();
            }
    
            private void RegisterRoutes()
            {
                RouteTable.Routes.Add(new ServiceRoute("theLandSocial", new WebServiceHostFactory(), typeof(ThePocketofResistance.theMapSocialServices.theLandSocial)));
            }
        }
    }
    
    I then post my global.ascx to the root of my discountasp site, and the dll for my service to the bin folder. At this point a request to my site at http://www.thepocketofresistance.com/ returns a blank page, this happens when I point at http://www.thepocketofresistance.com/thelandsocial/map. I'm not sure why I am not getting an error message or anything. It is probably a stupid mistake.

    I did check mime types and application/json was not added so I created it (although I am not sure why extension to use, I tried .json, but it looks like the response on my localhost has no extension).

    Any thoughts on what I am doing wrong? Is there different configuration necessary on a hosted server that I am missing?

    Thanks!
     
  2. Okay, ignore me. I was being an idiot. I turned on tracing and found a 401.2 error. Then I realized I had no authentication providers allowed in IIS or in the web.config :) Turned anonymous on for now and it works like a charm!

    I had made so many changes to try to get this working while I was using godaddy, I had no idea what was on and off.

    Thanks!
     
  3. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    Glad you were able to find a solution. :)
     

Share This Page