MRX220518
Rxma1805
2019-01-03 09:21

WCF 静态变量被回收了,为什么?

5
  • c#
  • asp.net
  • microsoft
  • visual studio

STHISTools.ParamUrlCode.Url = url
STHISTools.ParamUrlCode.Url闲置时间较长就被回收了,为什么?

    public class STHISTools
{
                public class ParamUrlCode
     {

                        private static string url = "";

          public static string Url
         {
              get
              {
                  return url;
              }

              set
              {
                  url = value;
             }
         }
        }

}

public class Servie : IService
{
private string Url = "";
//
/// 测试WCF链接是否建立成功
///
///
public bool TestLink(string url)
{
try
{
STHISTools.ParamUrlCode.Url = url;
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(STHISTools.ParamUrlCode.Url);
myRequest.Method = "POST"; //设置提交方式可以为"get","head"等
myRequest.Timeout = 10000; //设置网页响应时间长度
myRequest.AllowAutoRedirect = false;//是否允许自动重定向
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
}
}
}

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答

为你推荐

换一换