I am having some problems getting some plain HTML to display before executing some ASP then redirecting to another page. Without Response.Flush the screen stays blank until it goes onto the next page and with a Response.Flush it errors with:
Response object error 'ASP 0156 : 80004005'
Header Error
/assets2/addasset.asp, line 87
The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.
My code is as follows:
<script Language="javascript">self.moveTo(0,0);self.resizeTo(screen.availWidth,screen.availHeight);</script>
<br><br><br>
<center>
<table width="60%" cellspacing="0" cellpadding="10" border="1" bordercolor="navy">
<tr><td bgcolor="FFFFCC" align="middle" valign="middle">
<font face="verdana" size="2">
Your PC details are being added to the asset register. This will take a few seconds, after which you will
receive a message letting you know you can close this window.
</font>
</td>
</tr>
</table>
</center>
<%
' These three lines mean the page displayed does not cache and so always displays ammendments immediately
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader "Cache-Control", "must-revalidate"
Response.AddHeader "Cache-Control", "no-cache"
Response.Flush
HostName=UCASE(MID(Request.ServerVariables("REMOTE_HOST"),1,5))
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Set DB = Server.CreateObject("ADODB.Connection")
Set TBL = Server.CreateObject("ADODB.RecordSet")
DB.Mode = adModeReadWrite
DB.Open ("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" + Server.MapPath("assets.mdb"))
Set fso = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
arrComputers = Array(HostName)
For Each strComputer In arrComputers
Set objScriptExec = objShell.Exec("ping -n 2 -w 100 " & strComputer )
strPingResults = LCase(objScriptExec.StdOut.ReadAll)
Manufacturer=""
Model=""
Memory=0
Speed=0
If InStr(strPingResults, "reply from") Then
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
Manufacturer=objItem.Vendor
Model=objItem.Name
Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
Memory=objItem.TotalVisibleMemorySize
Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
Speed=objItem.CurrentClockSpeed
Next
End If
TBL.Open "INSERT INTO Assets (HostName, Manufacturer, Model, Memory, Speed, LastLogin) VALUES ('" & strComputer & "', '" & Manufacturer & "', '" & Model & "', '" & Memory & "', '" & Speed & "', '" & Date() & "')", DB
Next
Set TBL=Nothing
Set DB=Nothing
Response.Redirect("addnametoasset.asp")
%>
Any ideas?
Thanks!
Ed
Response object error 'ASP 0156 : 80004005'
Header Error
/assets2/addasset.asp, line 87
The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.
My code is as follows:
<script Language="javascript">self.moveTo(0,0);self.resizeTo(screen.availWidth,screen.availHeight);</script>
<br><br><br>
<center>
<table width="60%" cellspacing="0" cellpadding="10" border="1" bordercolor="navy">
<tr><td bgcolor="FFFFCC" align="middle" valign="middle">
<font face="verdana" size="2">
Your PC details are being added to the asset register. This will take a few seconds, after which you will
receive a message letting you know you can close this window.
</font>
</td>
</tr>
</table>
</center>
<%
' These three lines mean the page displayed does not cache and so always displays ammendments immediately
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader "Cache-Control", "must-revalidate"
Response.AddHeader "Cache-Control", "no-cache"
Response.Flush
HostName=UCASE(MID(Request.ServerVariables("REMOTE_HOST"),1,5))
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Set DB = Server.CreateObject("ADODB.Connection")
Set TBL = Server.CreateObject("ADODB.RecordSet")
DB.Mode = adModeReadWrite
DB.Open ("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" + Server.MapPath("assets.mdb"))
Set fso = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
arrComputers = Array(HostName)
For Each strComputer In arrComputers
Set objScriptExec = objShell.Exec("ping -n 2 -w 100 " & strComputer )
strPingResults = LCase(objScriptExec.StdOut.ReadAll)
Manufacturer=""
Model=""
Memory=0
Speed=0
If InStr(strPingResults, "reply from") Then
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystemProduct", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
Manufacturer=objItem.Vendor
Model=objItem.Name
Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
Memory=objItem.TotalVisibleMemorySize
Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
Speed=objItem.CurrentClockSpeed
Next
End If
TBL.Open "INSERT INTO Assets (HostName, Manufacturer, Model, Memory, Speed, LastLogin) VALUES ('" & strComputer & "', '" & Manufacturer & "', '" & Model & "', '" & Memory & "', '" & Speed & "', '" & Date() & "')", DB
Next
Set TBL=Nothing
Set DB=Nothing
Response.Redirect("addnametoasset.asp")
%>
Any ideas?
Thanks!
Ed