Car.cs
[DataContract]
public class Car
{
[DataMember]
public string Id { get; set; }
[DataMember]
public Bitmap Image { get; set; }
}
ICarService.cs
[ServiceContract]
public interface ICarService
{
[OperationContract]
[WebGet(UriTemplate = "Car/{id}")]
Car GetCarId(string id);
}
CarService.svc.cs
public class CarService : ICarService
{
public Car GetCarId(string id)
{
var newCar = new Car
{
Id = id,
Image = new Bitmap("../../Atish.jpg")
};
return newCar;
}
}
web.config
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<services>
<service name="CarHaat.CarService">
<endpoint address="" behaviorConfiguration="restfulBehavior"
binding="webHttpBinding" bindingConfiguration="" contract="CarHaat.ICarService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost/bookservice" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="restfulBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
</configuration>
問題は....ブラウザでこのURL localhost:4765/CarService.svc/car/1にアクセスすると、次の例外が発生します。どうすれば解決できますか?? 画像をjson形式で返したい。