.NET ASP VB点击计数器



<%@ Page Title="Home Page" Language="VB" MasterPageFile="~/Site.Master" AutoEventWireup="false"
    CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Import Namespace="System.IO" %>

    <script language="VB" runat="server">

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            If Not Page.IsPostBack Then
                Dim nCount As Int32 = 0
                nCount = GetCounterValue()
                lblHitCount.Text = nCount.ToString()
            End If

        End Sub

        Private Function GetCounterValue() As Int32

            Dim ctrFile As StreamReader
            Dim ctrFileW As FileStream
            Dim sw As StreamWriter
            Dim strPath As String = Server.MapPath("indexcount.txt")
            Dim strCounterContents As String
            Dim nCounter As Int32

            If (File.Exists(strPath)) Then
                ctrFile = File.OpenText(strPath)
                strCounterContents = ctrFile.ReadLine().ToString()
                nCounter = Convert.ToInt32(strCounterContents)

                nCounter = 0

            End If

            nCounter += 1
            ctrFileW = New FileStream(strPath, FileMode.OpenOrCreate, FileAccess.Write)
            sw = New StreamWriter(ctrFileW)

            Return nCounter

        End Function


<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">

    <style type="text/css">

        .style2 {
            color: #000066;
        .style3 {
            text-decoration: underline;
        .style5 {
            color: #000066;
            font-weight: bold;



<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">

        <span class="style5"><strong>Welcome to Beebe Automotive Service!</strong></span>

        <span class="style2"><span class="style3">Location:</span> One mile North of Rock Falls 
        on Highway 85</span>

        <marquee class="style2"">We Are <span class="style3">Now Accepting Appointments</span>!!!</marquee>

    <p class="style2">
        <span class="style3">Call:</span> (715)672-3261

        <span class="style2">Or <span class="style3">Contact:</span> 
        <a href="mailto:customerservices@beebeauto.com" style="color: #3333FF">customerservices@beebeauto.com</a></span>

    <p class="style2">
        Like us on Facebook:  
        <a href="https://www.facebook.com/beebeauto" 
            style="color: #3333FF">Beebe Automotive Service

    <p class="style2">
        Thank you for visiting. You are visitor number: 

    <p class="style2">
        <asp:label ID="lblHitCount" runat="server" Height="38px" Width="200px" 
            Font-Bold="True" Font-Size="X-Large" ForeColor="#000066">



Server Error in '/' Application.

Runtime Error

Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. 

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

<!-- Web.Config Configuration File -->

        <customErrors mode="Off"/>

Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.

<!-- Web.Config Configuration File -->

        <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
  • 妮听咱话 回复


    编辑:嗯,你做了检查... 您可能需要打开调试一分钟。这是一个选择吗?


  • Wooll 回复



  • bipsam 回复

    我上传了indexcount ...


  • 第五以南 回复