在浏览器中显示时,防止在Web服务中的单词之间修剪空格 [英] Prevent trimming spaces between words in webservices while displaying in browser
本文介绍了在浏览器中显示时,防止在Web服务中的单词之间修剪空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在网络服务中使用以下代码。
I have the below code used in web services.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace StringTest
{
/// <summary>
/// Summary description for StringTest
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class StringTest : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld(string str)
{
return str;
}
}
}
When I provide the input as "Hello world", I'm getting the result as Hello world (Nine spaces between the words has been reduced to one).
How can i Prevent trimming spaces between words in webservices?
我尝试过:
What I have tried:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace StringTest
{
/// <summary>
/// Summary description for StringTest
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class StringTest : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld(string str)
{
return str;
}
}
}
推荐答案
这是HTML的功能:空格总是修剪。
但是,您可以用非空格字符替换空格:& nbsp;
That's a "feature" of HTML: spaces are always trimmed.
However, you can replace the spaces with "non blank space" characters:
Hello World
成为
Becomes
Hello World
这篇关于在浏览器中显示时,防止在Web服务中的单词之间修剪空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文