无法在 wcf Web 服务 URL 中传递电子邮件 ID



我有一个服务,我试图在我的wcf休息服务中传递EmailID,但我无法在rest url中发送EmailId。如果我传递简单的字符串,那么我的服务运行良好,但是当我在 url 中传递 EmailID 时,我会收到以下错误。

错误

The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

是服务.cs

[OperationContract]
[WebGet(UriTemplate = "myservice/{username}/{email}", ResponseFormat = WebMessageFormat.Json)]
bool myservice(string username, string email);

服务.cs

public bool myservice(string username, string email)
{
     if(username != "" && email !="")
         return true;
     else
         return false;
}

网络网无花果

<system.web>
   <compilation debug="true" targetFramework="4.0">
     <assemblies>
       <add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
     </assemblies>
   </compilation>    
   <httpRuntime requestPathInvalidCharacters="" requestValidationMode="2.0" relaxedUrlToFileSystemMapping="true"/>
   <pages validateRequest="false" />           
 </system.web>

我也试过这个。

<httpRuntime requestPathInvalidCharacters="" requestValidationMode="2.0" />       
<pages validateRequest="false" />

当我传递简单字符串时,我的服务运行良好,但是当我在 url 中传递 EmailID 时,我得到上述错误。如果有人有解决此问题的方法,请帮助我。

标签

我尝试了所有命中和试用,但最终无法在 Web 服务 url 中传递 EmailId。

我得到了上述问题的替代解决方案。但是,如果有些人有任何其他解决方案,请帮助我。这个答案是可以接受的。

替代解决方案。

[OperationContract()]
[WebGet(UriTemplate = "/myservice/{username}?v={email}", ResponseFormat = WebMessageFormat.Json)]
string myservice(string username,string email);

最新更新