开发者

SharePoint 2007 HttpHandler NullReferenceException using SPContext.Current.Site/Web when called from jQuery

开发者 https://www.devze.com 2023-01-14 06:39 出处:网络
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 NullRefe

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?


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!.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号