【发布时间】:2014-04-02 06:45:29
【问题描述】:
我有一项服务,我想在我的 wcf 休息服务中传递 EmailID,但我无法在休息 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.
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 时,我得到了上述错误。如果有人对此问题有解决方案,请帮助我。
标签
【问题讨论】:
-
emailid 中是否有“@”?该字符在 URL 中是非法的。
-
是的,Email id 也有
@和dot。
标签: c# web-services wcf rest asp.net-4.0