Error
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS0120: An object reference is required for the non-static field, method, or property 'OCMS.ping_rply.label1' Source Error:
|
Line 28: PingReply pingReply = pingClass.Send(address, timeout);
Line 29: return pingReply.RoundtripTime;
Line 30: label1.Text = new Ping().Send("www.google.com").RoundtripTime.ToString() + "ms";
Line 31:
Line 32:
|
Source File: c:\inetpub\wwwroot\OCMS\OCMS\ping_rply.aspx.cs Line: 30
Show Detailed Compiler Output:
Show Complete Compilation Source:
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.9206.0
<asp:Label runat="server" ID="label1"></asp:Label>
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
long time = PingAddress("www.youtube.com", 1000);
}
}
private static long PingAddress(string address, int timeout)
{
try
{
Ping pingClass = new Ping();
PingReply pingReply = pingClass.Send(address, timeout);
return pingReply.RoundtripTime;
label1.Text = new Ping().Send("www.google.com").RoundtripTime.ToString() + "ms";
}
catch (Exception e)
{
}
return -1;
}