如何检查内部站点是否正常运行 [英] How to check if internal site is up and working

查看:57
本文介绍了如何检查内部站点是否正常运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果有人可以向我提供代码以检查Intranet网站是否正常工作.

If anyone could provide me with the code to check if intranet site is working .

namespace WebApplication4
{
    public partial class _Default : System.Web.UI.Page
    {
       public static bool UrlIsValid(string url)
       
       {    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); 
           request.Proxy = null;  
           try
    {        HttpWebResponse response = (HttpWebResponse)request.GetResponse();     
               
               return true;    }  
           
           catch //If exception thrown then couldn''t get response from address  
           {        return false;    }
       }
        private void Page_Load(object sender, EventArgs e)
        {   
            
            Response.BufferOutput = true;
        string url = "http://www.srv123.com" ;    
            if (UrlIsValid(url))
               Response.Redirect(url);  
  
            else
         Response.Redirect ("http://www.yahoo.com/") ;    
        }



我也尝试过其他方法,但是一切仅适用于外部站点.



I have tried others too but everything works only for external sites

推荐答案

您到目前为止尝试了什么?不鼓励在不花力气的情况下索要代码.

关于网站是否正常运行,您始终可以在代码中对其内部进行点击.根据响应类型,您可以确定站点是否正常运行.有什么想法吗?试试吧.

更新:
看看这些链接:
C#Ping组件 [使用C#的异步Ping [
What have you tried so far? Asking for code without showing any effort is not encouraged.

About site being up or not, you can always hit it internally in your code. Based on the response type you can determine whether the site is up or not. Thoughts? Try.

UPDATE:
Have a look at these links:
C# Ping Component[^]
Asynchronous Ping using C#[^]


使用
Use Ping[^] to see if there is a response.


这篇关于如何检查内部站点是否正常运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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