如何在没有进程模式的情况下在asp.net中进行访问 [英] How to do visitors count in asp.net without in process mode
本文介绍了如何在没有进程模式的情况下在asp.net中进行访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
访问者在没有处理模式的情况下计数asp.net,如文本文件,xml文件,数据库。
visitors count in asp.net without in process mode like text file,xml file,database.
推荐答案
转到Global.asax页面并添加以下代码
Go to Global.asax page and add the following code
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
Application["NoOfVisitors"] = 0;
}
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
Application.Lock();
Application["NoOfVisitors"] = (int)Application["NoOfVisitors"] + 1;
Application.UnLock();
}
现在打开您的aspx页面并编写以下代码
Now open your aspx page and write the following code
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1"runat="server">
<table>
<tr>
<td>
<b>No of Visits:</b>
</td>
<td>
<asp:Label ID="lblCount" runat="server" ForeColor="Red" />
</td>
</tr>
</table>
</form>
</body>
</html>
现在打开你的cs文件添加以下代码
Now open your cs file and add the following code
protected void Page_Load(object sender, EventArgs e)
{
lblCount.Text = Application["NoOfVisitors"].ToString();
}
参考
http://www.aspdotnet-suresh.com/2013/11 /asp-net-count-number-of-visitors-in-Website.html [ ^ ]
这篇关于如何在没有进程模式的情况下在asp.net中进行访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文