Question

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. If I Pass simple string then my service run fine but when i pass EmailID in url then I get as below error.

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

[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>

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. If anyone have solution for this problem then please help me.

Tags

Was it helpful?

Solution

I tried my all hit and trial but unable to pass EmailId in web service url but at last.

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top