EDIT: Tóm tắt: Có vẻ như ứng dụng web của tôi có thể được truy cập bởi bất kỳ ai (chỉ có firefox hoặc chrome) và bởi tôi sử dụng máy tính chính của tôi. Nếu tôi cố gắng truy cập http://luiscarlosch.com/WebFormClean.aspx từ bất kỳ mạng LAN nào khác của tôi, bạn sẽ gặp phải lỗi 405405: Phương pháp không được phép
Tôi hoàn toàn có thể gọi phương thức web WCF từ máy chủ cục bộ. Tôi đã xuất bản lên máy chủ này: http://luiscarlosch.com/WebFormClean.aspx (chỉ có firefox hoặc chrome) với công cụ xuất bản Visual Studio và nó hoạt động tốt. Vấn đề là khi thử truy cập nó từ một máy tính khác. Tôi nhận được 405: Phương pháp không được phép. Nhưng It doest làm cho tinh thần bởi vì nó hoạt động tốt khi tôi truy cập nó từ xa từ máy tính nhà xuất bản như tôi đã nói. Bất kỳ ý tưởng nào?
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ContactProxy
{
[WebGet()]
[OperationContract]
public Contact getByID(int IDContact)
{
Contact contact = new Contact(IDContact);
return contact;
}
[OperationContract]
public EntityData insertEntityData(int IDEntityDataFieldType, int IDContact, String value)
{
//Contact contact = new Contact();
// contact.insertEntityData(IDEntityDataFieldType, IDContact, value);
EntityData entityData = new EntityData();
entityData.save(IDEntityDataFieldType, IDContact, value);
return entityData;
}
}
Cả hai phương pháp đều không hoạt động.
Tôi vừa nhận thấy một số người dùng có thể truy cập http://luiscarlosch.com/WebFormClean.aspx vì họ thay đổi giá trị. Vì thế. một số khách hàng có thể đọc các phương pháp nhưng một số không thể. Điều này sẽ xảy ra.
Web Config
<?xml version="1.0"?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<customErrors mode="Off"/>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors" >
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="WebApplicationTest.WCFProxy.EmployeeProxyAspNetAjaxBehavior">
<enableWebScript />
</behavior>
<behavior name="WebApplicationTest.WCFProxy.EntityDataFieldCollectionProxyAspNetAjaxBehavior">
<enableWebScript />
</behavior>
<behavior name="WebApplicationTest.WCFProxy.Service1AspNetAjaxBehavior">
<enableWebScript />
</behavior>
<behavior name="WebApplicationTest.WCFProxy.ContactProxyAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<services>
<service name="WebApplicationTest.WCFProxy.EmployeeProxy" behaviorConfiguration="MyServiceTypeBehaviors" >
<endpoint address="" behaviorConfiguration="WebApplicationTest.WCFProxy.EmployeeProxyAspNetAjaxBehavior"
binding="webHttpBinding" contract="WebApplicationTest.WCFProxy.EmployeeProxy" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
<service name="WebApplicationTest.WCFProxy.EntityDataFieldCollectionProxy" behaviorConfiguration="MyServiceTypeBehaviors" >
<endpoint address="" behaviorConfiguration="WebApplicationTest.WCFProxy.EntityDataFieldCollectionProxyAspNetAjaxBehavior"
binding="webHttpBinding" contract="WebApplicationTest.WCFProxy.EntityDataFieldCollectionProxy" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
<service name="WebApplicationTest.WCFProxy.Service1">
<endpoint address="" behaviorConfiguration="WebApplicationTest.WCFProxy.Service1AspNetAjaxBehavior"
binding="webHttpBinding" contract="WebApplicationTest.WCFProxy.Service1" />
</service>
<service name="WebApplicationTest.WCFProxy.ContactProxy" behaviorConfiguration="MyServiceTypeBehaviors" ><!--new-->
<endpoint address="" behaviorConfiguration="WebApplicationTest.WCFProxy.ContactProxyAspNetAjaxBehavior"
binding="webHttpBinding" contract="WebApplicationTest.WCFProxy.ContactProxy" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<bindings />
<client />
</system.serviceModel>
</configuration>
Có phải dịch vụ REST không? Chúng tôi cần thêm thông tin (hợp đồng, cấu hình, v.v.) ... –
Thankx. Tôi chỉ đăng một số thông tin thêm. –
Dường như IIS là khối POST (hoặc các yêu cầu khác). – leppie