예제 #1
0
파일: Default.aspx.cs 프로젝트: 2Nifty/PFC
    public bool UrlIsValid(string Url)
    {
        Stream      sStream;
        WebRequest  URLReq;
        WebResponse URLRes;

        try
        {
            URLReq  = WebRequest.Create(Url);
            URLRes  = URLReq.GetResponse();
            sStream = URLRes.GetResponseStream();
            string reader = new StreamReader(sStream).ReadToEnd();
            return(true);
        }
        catch (SocketException se)
        {
            return(false);
        }
    }
예제 #2
0
    private bool IsDomainURLOK()
    {
        bool flag = false;

        System.IO.Stream           sStream;
        System.Net.HttpWebRequest  URLReq;
        System.Net.HttpWebResponse URLRes;

        try
        {
            URLReq  = (System.Net.HttpWebRequest)System.Net.WebRequest.Create("http://" + txtDomainName.Text.ToLower().Replace("http://", "") + "/WebServices/GlobalWebService.asmx");
            URLRes  = (System.Net.HttpWebResponse)URLReq.GetResponse();
            sStream = URLRes.GetResponseStream();
            string reader = new System.IO.StreamReader(sStream).ReadToEnd();
            flag = true;
        }
        catch (Exception ex)
        {
            flag           = false;
            txtTest.Value += "  " + ex.ToString();
            //gClass.AddErrorLogData("0", "", Request.Url.Host, "IsDomainURLOK", "Add new/Update Organization", ex.ToString());
        }
        return(flag);
    }
예제 #3
0
    public static bool getURLResponse(string urlPath)
    {
        HttpWebRequest  URLReq;
        HttpWebResponse URLRes;

        try
        {
            URLReq         = (HttpWebRequest)WebRequest.Create(urlPath);
            URLReq.Timeout = 5000;
            URLRes         = (HttpWebResponse)URLReq.GetResponse();
            if (URLRes.StatusCode == HttpStatusCode.OK)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        catch (Exception ex)
        {
            return(false);
        }
    }