Azure函数HttpTrigger,未在属性中使用HttpMethods类 [英] Azure functions HttpTrigger, not using HttpMethods class in attribute
本文介绍了Azure函数HttpTrigger,未在属性中使用HttpMethods类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
AzureFunctions中的功能为什么需要使用
Why do functions in AzureFunctions requires to use
[HttpTrigger(AuthorizationLeve.Anonymous, "get")]
代替
[HttpTrigger(AuthorizationLeve.Anonymous, HttpMethods.Get)]
我当然不能使用
HttpMethods.Get.ToString()
如果语言不允许调用属性中的函数
becase language does not allow to call functions in Attributes
并创建自己的
public static class HttpMethodsStrings
{
public const string Get = "get";
}
似乎很多余,因为.NET已经提供了HttpMethods.
seems redundant since .NET already provides HttpMethods.
推荐答案
您可以使用System.Net.WebRequestMethods.Http.X
常量代替硬编码的字符串("get","post").我整理了一段代码并对其进行了调试,它工作正常.
相同的代码片段显示如下-
You can use System.Net.WebRequestMethods.Http.X
constants instead of hard coded strings ("get", "post"). I have put together the piece of code and debugged it and it works fine.
The snippet of the same is shown below -
这篇关于Azure函数HttpTrigger,未在属性中使用HttpMethods类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文