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

时间:2014-04-02 06:45:30

标签: c# web-services wcf rest asp.net-4.0

我有一项服务,我想在我的wcf休息服务中传递EmailID,但我无法在休息网址中发送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. 

IService.cs

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

Service.cs

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

web.cofig

<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时,我得到上述错误。如果有人能解决这个问题,那么请帮助我。

标签

1 个答案:

答案 0 :(得分:0)

我尝试了所有热门和试用但无法通过网络服务网址传递EmailId,但最后还是。

我为上述问题找到了另一种解决方案。但如果其他人有任何其他解决方案,那么请帮助我。这个答案是可以接受的。

替代解决方案。

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