简体   繁体   English

无法在WCF Web服务URL中传递EmailID

[英]Unable to pass EmailID in wcf web service url

I have a service and I am tring to pass EmailID in my wcf rest service but I an Unable to send EmailId in rest url. 我有一项服务,我想在wcf rest服务中传递EmailID,但无法在rest url中发送EmailId。 If I Pass simple string then my service run fine but when i pass EmailID in url then I get as below error. 如果我传递简单字符串,则我的服务运行良好,但是当我在url中传递EmailID时,出现以下错误。

Error 错误

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 IService.cs

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

Service.cs Service.cs

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

web.cofig 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>

I tried this one also. 我也尝试过这个。

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

When I pass simple string then my service run fine but when I pass EmailID in url then I get as above error. 当我传递简单字符串时,我的服务运行良好,但是当我在URL中传递EmailID时,出现上述错误。 If anyone have solution for this problem then please help me. 如果有人有解决此问题的方法,请帮助我。

Tags 标签

I tried my all hit and trial but unable to pass EmailId in web service url but at last. 我尝试了所有尝试和尝试,但最终无法在Web服务URL中传递EmailId。

I got alternative solution for above problem.But if some on have any another solution for it then please help me.That answer will be acceptable. 我为上述问题找到了替代解决方案,但是如果有人对它有其他解决方案,请帮助我,这个答案是可以接受的。

Alternative solution. 替代解决方案。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM