Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/06/2003, 03:08
sqa212
 
Fecha de Ingreso: mayo-2003
Mensajes: 866
Antigüedad: 22 años
Puntos: 0
Pregunta problema: Contar usuarios activos

***********He creado un archivo (counter.txt) que se encuentra en el directorio raiz del sitio.
***********En functions.asp introduzco la funcion
***********En count.asp pongo esto:
<!-- #include file="functions.asp" -->
<%'contarusuarios activos
' Every time we count a user we will put the
' latest count value in the session variable "TotalCount"
' If Session Variable TotalCount is empty
' that mean this user is new and session variable
' But if Session Variable already has the value
' Then we will not count this user again.

If IsEmpty(Session("TotalCount")) Then
Call CountThisUser
End If %>
Luego en cada pagina que quiero que se me muestren los usuarios activos introduzco:
<!--#Include File="Count.asp"-->

El problema es que cuando se carga la pagina de inicio.asp (que incluye count.asp) aparece esto, pero si actualizo el navegador, el error desaparece.
1- ¿Cómo puedo solucionar el problema?
2- Otra duda es, si Count.asp tiene <!-- #include file="functions.asp" --> y inicio.asp
<!--#Include File="Count.asp"-->, ¿Necesito incluir en inicio.asp tambien <!-- #include file="functions.asp" --> o por el hecho de incluir <!--#Include File="Count.asp"--> incluye ya tambien functions.asp?


No se puede mostrar la página
HTTP 500.100. Error interno del servidor: error de ASP
Servicios de Internet Information Server
· Tipo de error:
Error de Microsoft VBScript en tiempo de ejecución (0x800A003A)
El archivo ya existe
/forojb/functions.asp, line 128
· Tipo de explorador:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
Página:
GET /forojb/foro.asp
<% 'Contar Uusarios en el sitio
' It is good practice to use Functions and Sub procedure
' Because all the variables being used in sub or function
' are automatically destroyed when Sub or Function finish
' processing the code.
' So you can use these Variables again in other functions
Sub CountThisUser()

Dim objFSO ' FileSystemObject
Dim objTS ' TextStreamObject

Dim strFileName ' Counter text File Name
Dim intOldCount
Dim intNewCount

' Specify the Text file to store count value
' Because We Set Create = True
' File will be Created if it does not exist

strFileName = Server.MapPath("Counter.txt")

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

If objFSO.FileExists(strFileName) Then
Set objTS = objFSO.OpenTextFile(strFileName, 1)
Else
Set objTS = objFSO.CreateTextFile(strFileName, true)
End If

If Not objTS.AtEndOfStream Then
intoldCount = objTS.ReadAll
Else
intoldCount = 0
End If

objTS.Close

intNewCount = intOldCount + 1

' Store the value of intNewCount in Session Variable
' So you can use it on different pages
Session("TotalCount")= intNewCount

' Write intNewCount value back to text file
' LA FILA DE ABAJO ES LA QUE DA EL ERROR (LINEA 128)
Set objTS = objFSO.CreateTextFile(strFileName, false)
objTS.Write intNewCount

objTS.Close

Set objFSO = Nothing
Set objTS = Nothing
End Sub
%>

Por mas vueltas que le doy no se como solucinar el problema, se podria hacer algo asi como onload refresh???

Última edición por sqa212; 11/06/2003 a las 03:08