首页 > 解决方案 > 我是否需要在 WCF Web 服务中调用 URLDecode

问题描述

我有一个用 c# 编写的 WCF Web 服务。我有一个像这样定义的 Put 方法:

[OperationContract]
[WebInvoke(Method = "PUT", UriTemplate = "MobileDevice?name={name}&make={make}&model={model}&serial={serial}&software={software}")]
MobileDeviceView RegisterMobileDevice(string name, string make, string model, string serial, string software);

在我的实现中,我需要调用HttpUtility.UrlDecode(name);每个参数吗?

public MobileDeviceView RegisterMobileDevice(string name, string make, string model, string serial, string software)
{
        string safeName = HttpUtility.UrlDecode(name);
        string safeMake = HttpUtility.UrlDecode(make);
        string safeModel = HttpUtility.UrlDecode(model);
        string safeSerial = HttpUtility.UrlDecode(serial);
        string safeSoftware = HttpUtility.UrlDecode(software);
        ...
}

标签: c#web-serviceswcfurldecode

解决方案


推荐阅读