何时用以下方法装饰方法 [英] When to decorate a method with
本文介绍了何时用以下方法装饰方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用jquery来调用页面方法时,我总是像
那样装饰我的方法
when i work with jquery to call page method then i always decorate my method like
[WebMethod]
public static string GetItems()
{
//here will be my code
}
所以我想知道何时需要装饰我的方法,如
so i want to know when i need to decorate my method like
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static string GetItems()
{
//here will be my code
}
请在强制使用示例代码的情况下向我展示ScriptMethod的重要性.谢谢
please show me the importance of ScriptMethod with sample code when it is mandatory. thanks
推荐答案
您可以使用ScriptMethod选择使用的内容(动词,GET/POST等)以及响应格式(JSON/XML等). br/>
这里是更多:
MSDN上的 ScriptMethod [此处 [ ^ ].
干杯.
You can choose what''s used (verbwise, GET/POST etc) as well as the response format (JSON/XML etc) with ScriptMethod.
Here''s more:
ScriptMethod on MSDN[^]
WebMethod was traditionally used with web services so that clients would be able to call them via script. I have used it to return simple values and XML. JSON is a different beast, a gentler, kinder, lightweight beast that is fun to snuggle with. See here[^] for details.
Cheers.
这篇关于何时用以下方法装饰方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文