Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9041511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:15:23+00:00 2026-06-16T10:15:23+00:00

I have created an HttpHandler that I will be using with a jquery-Ajax call.

  • 0

I have created an HttpHandler that I will be using with a jquery-Ajax call.

This HttpHandler will access the database and check something related to the currently singed in user.

The user is considered signed in by using the Session, with an attribute called user_id.

Session["user_id"] = userId;

I tried to retrieve this Session in the HttpHandler but that doesn’t seem to work.

So I thought about sending the user_id as a parameter.

    var user_id = //Retrieved in some way...
    $.ajax({
        url: 'QuestionRate.ashx?id=user_id',
        success: function (msg, status, xhr) {
            alert(msg);
        },
        error: function () {
            alert(msg);
        }
    });

But this really seems like a bad idea, anyone who will read the codes can simply access the Handler with the id that he wants.

So what can I do in this situation? I want the Handler to get the user_id for database access, yet I wanna make sure that this user_id is the actual id of the signed in user. There’s no way to access the Session in the Handler?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T10:15:25+00:00Added an answer on June 16, 2026 at 10:15 am

    Passing session id with an ajax call doesn’t sound good.

    You should mark your handler with the marker IReadOnlySessionState interface and access to session as read-only via HttpContext.Current.Session instance.


    Code sample:

    public class FooHandler : IHttpHandler, IReadOnlySessionState 
    {
        public bool IsReusable
        {
            get { return false; }
        }
    
        public void ProcessRequest(HttpContext context)
        {
            string user_id = context.Session["user_id"].ToString();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created some JQuery that will expand a div 'popup' on hover and
I have created a http handler fro my Jquery ajax call. which is working
I have created an android application that calls (using kSOAP library) a SOAP based
I have an application that depends on a generic HttpHandler I created, and it
I have created a HttpHandler that I would like to use with my asp.net
I am using IIS 6 on 2003. I have created a HTTP handler dll
I have created a function that shows/hides different messages according to a combination of
I'm working on building an HTTPHandler that will serve up plain text for use
Assuming that I have already fetched a byte array from the database, how do
I have created a HttpHandler for WMV files. I have also registered it in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.