如何在asp.net中限制用户注册者的数量 [英] How to restrict no of user registrants in a day in asp.net

查看:100
本文介绍了如何在asp.net中限制用户注册者的数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正在开发一个汽车预订申请..我有一个限制一天没有预订的情况..如果它超过警报信息应该来..?



如何为上述代码编码..



删除了SHOUTING - OriginalGriff [/ edit]

Am developing a car booking application..I have a scenario for restricting no of bookings to 10 in a day.. If it exceeds alert message should come..?

How to code for the above..

[edit]SHOUTING removed - OriginalGriff[/edit]

推荐答案

oid Application_Start(object sender, EventArgs e)
{
    Application["ActiveSessions"] = 0;
}

void Session_Start(object sender, EventArgs e)
{
    try
    {
        Application.Lock();

        int activeSessions = (int) Application["ActiveSessions"] + 1;
        int allowedSessions = 10; // retrieve the threshold here instead

        Application["ActiveSessions"] = activeSessions;

        if (activeSessions > allowedSessions)
            System.Web.HttpContext.Current.Response.Redirect("~/UserLimitReached.aspx", false);
    }
    finally
    {
        Application.UnLock();
    }
}

void Session_End(object sender, EventArgs e)
{
    Application.Lock();
    Application["ActiveSessions"] = (int)Application["ActiveSessions"] - 1;
    Application.UnLock();
}


oid Application_Start(object sender, EventArgs e)
{
    Application["ActiveSessions"] = 0;
}

void Session_Start(object sender, EventArgs e)
{
    try
    {
        Application.Lock();

        int activeSessions = (int) Application["ActiveSessions"] + 1;
        int allowedSessions = 10; // retrieve the threshold here instead

        Application["ActiveSessions"] = activeSessions;

        if (activeSessions > allowedSessions)
            System.Web.HttpContext.Current.Response.Redirect("~/UserLimitReached.aspx", false);
    }
    finally
    {
        Application.UnLock();
    }
}

void Session_End(object sender, EventArgs e)
{
    Application.Lock();
    Application["ActiveSessions"] = (int)Application["ActiveSessions"] - 1;
    Application.UnLock();
}


你可以在存储过程中处理这个问题,你应该检查一下userid并且在每个用户的日期没有交易,你可以很容易地得到在插入新注册之前插入了多少条记录。
you can handle this in stored procedure, you should check with userid and no of transaction per user on the date, you can easily get how many records inserted before you insert a new registration.


这篇关于如何在asp.net中限制用户注册者的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆