WebGet在功能上是否等效于WebInvoke(Method ="GET")? [英] Is WebGet functionally equivalent to WebInvoke(Method = "GET")?

查看:48
本文介绍了WebGet在功能上是否等效于WebInvoke(Method ="GET")?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题已经问过我要问的问题,但是我想对回答.

This question already asks what I'm asking, but I want some clarification on the answer.

答案表明 WebGet WebInvoke 相似,并且主要区别是 Method 参数.

The answer states that WebGet and WebInvoke are similar, and that the primary difference is the Method parameter.

但是,如果将 Method 参数设置为"GET" ,它实际上在功能上是否等效,或者还有其他区别吗?

But if the Method parameter is set to "GET", is it actually functionally equivalent, or are there other differences?

推荐答案

它们只是标记属性,最终在功能上是100%等效的.解释这些属性的唯一方法是 WebHttpBehavior :: GetWebMethod 方法,其功能很简单:

They are simply marker attributes and end up being 100% functionally equivalent. The only thing that interprets these attributes is the WebHttpBehavior::GetWebMethod method and its functionality is simply:

internal static string GetWebMethod(OperationDescription od)
{
    WebGetAttribute webGetAttribute = od.Behaviors.Find<WebGetAttribute>();
    WebInvokeAttribute webInvokeAttribute = od.Behaviors.Find<WebInvokeAttribute>();
    WebHttpBehavior.EnsureOk(webGetAttribute, webInvokeAttribute, od);
    if (webGetAttribute != null)
    {
        return "GET";
    }
    if (webInvokeAttribute == null)
    {
        return "POST";
    }
    return webInvokeAttribute.Method ?? "POST";
}

这篇关于WebGet在功能上是否等效于WebInvoke(Method ="GET")?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆