I'm developing a visual web part for Sharepoint 2010. This webpart needs to get some data via AJAX. So I went for the HTTP handler + jQuery solution posted here.
But I'm getting a problem when trying to access the handler. I get the famous .NET error page:
Server Error in '/' Application. Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "Off".
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's configuration tag to point to a custom error page URL.
So I checked the server's Event viewer to see the details of the error. This is what is causing it:
Event code: 3006
Event message: A parser error has occurred.
Event time: 8/4/2011 2:08:17 PM
Event time (UTC): 8/4/2011 6:08:17 PM
Event ID: 71c80726be98453ab77a7c1d474cbf7c
Event sequence: 5
Event occurrence: 2
Event detail code: 0
Process information:
Process ID: 6200
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE
Exception information:
Exception type: HttpParseException
Exception message: Could not create type 'MyNamespace.MyHandler'.
Request information:
Request URL: http://mysharepointurl/_layouts/MyNamespace/MyHandler.ashx
Request path: /_layouts/MyNamespace/MyHandler.ashx
User host address: xxx.xxx.xxx.xxx
User:
Is authenticated: False
Authentication Type:
Thread account name: NT AUTHORITY\NETWORK SERVICE
Thread information:
Thread ID: 11
Thread account name: NT AUTHORITY\NETWORK SERVICE
Is impersonating: True
Stack trace: at System.Web.UI.SimpleWebHandlerParser.GetType(String typeName)
at System.Web.UI.SimpleWebHandlerParser.GetTypeToCache(Assembly builtAssembly)
at System.Web.Compilation.SimpleHandlerBuildProvider.GetGeneratedType(CompilerResults results)
at System.Web.Compilation.BuildProvider.CreateBuildResult(CompilerResults results)
at System.Web.Compilation.BuildProvider.GetBuildResult(CompilerResults results)
at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.UI.SimpleHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
at System.Web.UI.SimpleHandlerFactory.GetHandler(HttpContext context, String requestType, String virtualPath, String path)
at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
This is MyHandler.ashx
<%@ WebHandler Language="C#" Class="MyNamespace.MyHandler" CodeBehind="MyHandler.cs" %>
As you can see I'm missing the Assembly directive. But I don't know what to put in it. Where do I get the KeyToke, Name, etc?