Tôi đã tìm kiếm xung quanh cố gắng giải quyết vấn đề tôi đang gặp phải với WCF. Tôi rất mới đến WCF vì vậy tôi đã không chắc chắn chính xác những gì đang xảy ra.Tại sao AspNetCompatibilityRequirementsMode.Allowed sửa lỗi này?
Tôi đang sử dụng Visual Studio 2010 và đã làm Trang web mới-> Dịch vụ WCF. Tôi đã tạo dịch vụ của mình và trong tệp cấu hình, nếu tôi đặt aspNetCompatibilityEnabled="true"
, tôi sẽ gặp lỗi này khi truy cập dịch vụ thông qua trình duyệt web của tôi.
The service cannot be activated because it does not support ASP.NET compatibility.
ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config
or add the AspNetCompatibilityRequirements attribute to the service type with RequirementsMode
setting as 'Allowed' or 'Required'.
Tôi không hiểu ý nghĩa của điều này. Lý do tại sao aspNetCompatibilityEnabled="true"
gây ra lỗi này khi [AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)]
sửa lỗi.
Với tôi, có vẻ như họ cũng làm như vậy. Ngoài ra, nếu không có thuộc tính đó thì Silverlight không thể gọi các phương thức WCF của tôi. Tại sao vậy?
Đây là tập tin cấu hình của tôi nếu cần thiết:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<customErrors mode="Off"/>
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="LargeBuffer" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
</basicHttpBinding>
</bindings>
<services>
<service name="Services.Exporter">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="LargeBuffer"
contract="Services.IExporter" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment
multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Vì vậy, câu hỏi của tôi là, tại sao không thêm Compatibility thuộc tính khắc phục điều đó? Ngoài ra, tại sao nó cần thiết cho silverlight để có nó?
Câu hỏi, trang trí phù hợp này sẽ là gì nếu tôi đặt nó thành đúng? – Justin
Tùy thuộc vào việc dịch vụ của bạn có cần các mục có sẵn với đường dẫn ASP.NET hay không. Nếu bạn không thực sự quan tâm, thì bạn sẽ đặt nó thành 'RequirementsMode.Allowed'. Nếu bạn dựa vào các thành phần đó (như Session), thì bạn nên đặt nó thành 'RequirementsMode.Required'. –