配置设置,仅将应用程序限制为100个用户 [英] config settings to restrict applications for 100 users only
本文介绍了配置设置,仅将应用程序限制为100个用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只需要允许100个用户访问我的网站,怎么办?
web.config设置的内容
i need to allow 100 users only to access my site, how ?
what r the web.config settings
推荐答案
在 global.asax 文件中编写与整个应用程序交互的代码.
示例代码如下:
Write code in global.asax file which interacts with the entire application.
The sample code is given below:
void Application_OnStart(Object Sender, EventArgs E)
{
Application["CurrentUsers"] = 0;
}
void Session_OnStart(object Sender, EventArgs E)
{
Application.Lock();
Application["CurrentUsers"] = System.Convert.ToInt32(Application["CurrentUsers"]) + 1;
Application.UnLock();
}
void Session_OnEnd(object Sender, EventArgs E)
{
Application.Lock();
Application["CurrentUsers"] = System.Convert.ToInt32(Application["CurrentUsers"]) - 1;
Application.UnLock();
}
此后,您可以根据需要处理此方案.
此处的详细信息: http://www.aspdotnetfaq.com/Faq/How-to-show-number-of-online-users-visitors-for-ASP-NET-website.aspx [
Hereafter you can handle the scenario as per your need.
Details here: http://www.aspdotnetfaq.com/Faq/How-to-show-number-of-online-users-visitors-for-ASP-NET-website.aspx[^]
这篇关于配置设置,仅将应用程序限制为100个用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文