Garrett
Garrett

Reputation: 1688

WCF Rest Method - This webpage is not available

I have a few methods implemented in a service I am making using the WCF Rest Template as a base.

These methods are working fine and are returning Json data.

However, I implemented a method which returns a List of Objects, which continuously seems to give me a "This webpage is not available" error. I have no idea how to debug this or what may be the cause. Does anyone have any advice?

[WebGet(UriTemplate = "GetCars/{TypeId}", RequestFormat=WebMessageFormat.Json)]
public List<Car> GetCars(String TypeId)
{
    CarFilter carFilter = new CarFilter();

    carFilter.requestType = "product";
    carFilter.numberOfCars = -1;// Convert.ToInt32(numberOfCars);
    carFilter.carIdTo = -1;//Convert.ToInt32(carIdTo);
    carFilter.carIdFrom = -1;//Convert.ToInt32(carIdFrom);

    return CarDataAccess.GetCar(Convert.ToInt32(TypeId), carFilter);
}

Thanks.

Upvotes: 2

Views: 746

Answers (1)

Bob Horn
Bob Horn

Reputation: 34315

Two things to check. First, see if this is a KnownType issue by adding the [ServiceKnownType] attribute:

[ServiceKnownType]

Also, pre-.NET 4.0, if this is WCF, you still need your OperationContract attribute on the method. Try this:

[OperationContract]
[WebGet(UriTemplate = "GetCars/{TypeId}", RequestFormat=WebMessageFormat.Json)]
public List<Car> GetCars(String TypeId)

Upvotes: 2

Related Questions