Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have the need to develop a custom HttpHandler in SharePoint. To start, I just coded up a simple example: http://pastebin.com/HXLjR2xT. On line 35 or 36 of that code I get a NullReferenceException thrown if I call my HttpHander page from jQuery. But if I call the page directly in my browser, I get the results I expect. I have seen some examples online for building an HttpHandler in SharePoint and calling it from jQuery and they don't seem to really do anything differently then I am. Ex: http://bobbybeckner.com/index.php/sharepoint-list-and-linq-using-jquery-and-ihttphandler/

Any ideas on why I can't seem to get the Current context from SPContext when I am calling from jQuery?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Ok, this was a really dumb mistake on my part, it actually turns out that I was requesting the wrong path in my jQuery ajax call. I was requesting url: "_layouts/MyStuff/MyHandler.ashx" which was trying to request "/Pages/_layouts/MyStuff/MyHandler.ashx" instead of "/_layouts/MyStuff/MyHandler.ashx". So, changing to the right path solved my problem. Boy don't I feel dumb now!.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.