大家帮帮忙,我的网站计数器在本地服务器能显示,但是上传到空间后,计数器的数字无法显示了。
我的代码是这样写的:
1、在网站目录下新建一个文本:txtcounter.txt 在文本填写1或其他数字2、新建一个asp文件:count.asp,加入以下代码:<% 
CountFile=Server.MapPath("txtcounter.txt") 
Set FileObject=Server.CreateObject("Scripting.FileSystemObject") 
Set Out=FileObject.OpenTextFile(CountFile,1,FALSE,FALSE) 
counter=Out.ReadLine 
Out.Close 
SET FileObject=Server.CreateObject("Scripting.FileSystemObject") 
Set Out=FileObject.CreateTextFile(CountFile,TRUE,FALSE) 
Application.lock 
counter= counter + 1 
Out.WriteLine(counter) 
Application.unlock 
Response.Write"document.write("&counter&")"
'为了在页面正确显示计数器的值,调用VBScript函数Document.write
Out.Close
%> 3、在需要计数的网页加入:总访问<script language="JavaScript" src="count.asp"></script>次

解决方案 »

  1.   

    须确定对txtcounter.txt所在目录的 写权限,还有txtcounter.txt文件本身的写权限
      

  2.   

    文件是否有操作权限利用HttpModule
    使用免费流量统计站点
    记录用户登录日志,通过IP记录流量
      

  3.   

     在Global.asax里面写:
     void Application_Start(object sender, EventArgs e) 
        {
            // 在应用程序启动时运行的代码
            Application["count"] = 1;
               }    void Session_Start(object sender, EventArgs e) 
        {
            // 在新会话启动时运行的代码
            Application.Lock();
            int c = Convert.ToInt32(Application["count"]);
            Application["count"] = c + 1;
            Application.UnLock();
            Session.Timeout = 15;//过期时间15分钟;
        }