views:

51

answers:

1

Hi. I have the next problem: I need to process only 1 request at a time from each user. Lets assume that server identifies each user be UserID, sent in query string. How can make the server work the way like FIFO (do not start processing next request until the previous is fully processed)? Should I use the named mutexes inside HTTP handler and assign the name to mutex by UserID?

Thanks in advance, Valentin

+2  A: 

When the first request comes, Set a flag in Session. Reset this flag only after the processing of the first request completes.

If the user requests again, without having the first request completed, just reject the request by returning from ProcessRequest() without any further line of code executed. Additionally you can reply the user back with appropriate status-message.

EDIT

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.SessionState;

namespace MyHandlers
{
    public class MyHttpHander : IHttpHandler,IRequiresSessionState
    {
        public bool IsReusable
        {
            get { return true; }
        }

        public void ProcessRequest(HttpContext context)
        {
            context.Response.Write("<h1><b>HttpHandler Test</b></h1>");
            context.Session["Test"] = "Invoke a session in HttpHandler.";
            context.Response.Write(context.Session["Test"]+"<br>");
            context.Response.Write("<a href='HttpHandlerCsharp.aspx'><b>return</b></a>");
        }
    }
} 
this. __curious_geek
Do you mean Session property of HttpContext?If so, it is 'null'.
Valentin
Yes. To do Session operations in HttpHandler, your handler should implement IRequiresSessionState interface. You can then access session object in your HttpContext witihn ProcessRequest().
this. __curious_geek