如何获得Web服务的状态

编程入门 行业动态 更新时间:2024-10-10 23:19:00
本文介绍了如何获得Web服务的状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我怎样才能得到Web服务的使用C#的状态?无论是成功完成,失败或挂起这样的。

How can I get the status of web service using C#? whether it is completed successfully, failed or pending like this.

推荐答案

首先,我发现这个问题的 Web服务数据库/网站状态

First i found this question Web Service For Database/Website Status

你应该试试这个code;

And you should try this code;

System.ServiceProcess.ServiceController sc = new System.ServiceProcess.ServiceController("myService"); return sc.Status

和您应该检查这个code;

And you should examine this code;

public static string PingHost(string args) { HttpWebResponse res = null; try { // Create a request to the passed URI. HttpWebRequest req = (HttpWebRequest)WebRequest.Create(args); req.Credentials = CredentialCache.DefaultNetworkCredentials; // Get the response object. res = (HttpWebResponse)req.GetResponse(); return "Service Up"; } catch (Exception e) { MessageBox.Show("Source : " + e.Source, "Exception Source", MessageBoxButtons.OK); MessageBox.Show("Message : " + e.Message, "Exception Message", MessageBoxButtons.OK); return "Host Unavailable"; } }

,你也应该看看;

And also you should look;

使用会话状态在Web服务

更多推荐

如何获得Web服务的状态

本文发布于:2023-11-28 17:43:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643354.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何获得   状态   Web

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!