How to fetch data in .ashx(handler) page ?

Posted by Rohik under Regular Expressions on 7/6/2010 | Views : 3361 | Status : [Member] | Replies : 2
Hi ,

I want to send session value to handler (.ashx) page.
I am calling Handler page in ajax call and sending data
I am placing code here


$.ajax({
type: "GET",
url: hn,
dataType: "json",
data: "{'AuthToken':'"+AuthToken+"','MileStoneId':'"+MileStoneId+"'}",
contentType: "application/json; charset=utf-8",
success: function(xData) {

alert("hI");


var obj = eval(xData);
}
});


here AuthToken and MileStoneId are session values


 var AuthToken = '<%=Session["AuthToken"]%>';
var MileStoneId ='<%=Session["MileStoneId"]%>';



but in hadler When i am fetching that

string Authtoken = context.Request.QueryString["AuthToken"];
int m = Convert.ToInt32(context.Request.QueryString["MileStoneId"]);


it returns null value.
please anybody tell me how to do that one..?

Thanks in advance

Happy Programming!!
Rohi



Responses

Posted by: Raja on: 7/6/2010 [Member] Starter

Up
0
Down
I do not think Session will work directly in the ashx file, you should write something like below

var authTok = context .Session["MileStoneId"]


Thank you

Regards,
Raja, USA

Rohik, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rohik on: 7/7/2010 [Member] Starter

Up
0
Down
Hi Raja,

Thanks !

I have tried context.session["MileStoneId"] but it gives error "Object reference not set to an instance of an object".

how to solve this one..?

Happy Programming!!
Rohi

Rohik, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response