Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 是否从web.config在WebMethod上设置CacheDuration?_Asp.net_Web Services_Asp.net 4.0 - Fatal编程技术网

Asp.net 是否从web.config在WebMethod上设置CacheDuration?

Asp.net 是否从web.config在WebMethod上设置CacheDuration?,asp.net,web-services,asp.net-4.0,Asp.net,Web Services,Asp.net 4.0,对于ASP.Net web服务,我希望能够在web.config中为所有webmethods或独立webmethods设置CacheDuration,以便在不重新编译解决方案的情况下对其进行调整 [WebMethod(CacheDuration=60)] 能做到吗?怎么做?VB 来源:这似乎是不可能的。在AppSettings中保存值可能吗?问题不是保存值,而是将值应用到webmethod。这显示了如何通过在代码中使用属性值设置缓存持续时间,正如我在问题中所做的那样。我想从web.config

对于ASP.Net web服务,我希望能够在web.config中为所有webmethods或独立webmethods设置CacheDuration,以便在不重新编译解决方案的情况下对其进行调整

[WebMethod(CacheDuration=60)]
能做到吗?怎么做?

VB


来源:

这似乎是不可能的。

在AppSettings中保存值可能吗?问题不是保存值,而是将值应用到webmethod。这显示了如何通过在代码中使用属性值设置缓存持续时间,正如我在问题中所做的那样。我想从web.config执行此操作
Public Class Service1
    Inherits System.Web.Services.WebService
    <System.Web.Services.WebMethod(CacheDuration:=60)> _
    Public Function ConvertTemperature(ByVal dFahrenheit As Double) _
                                       As Double
        ConvertTemperature = ((dFahrenheit - 32) * 5) / 9
    End Function
End Class
public class Service1 : System.Web.Services.WebService
{ 
    [System.Web.Services.WebMethod(CacheDuration=60)]
    public double ConvertTemperature(double dFahrenheit)
    {
       return ((dFahrenheit - 32) * 5) / 9;
    }
}