I would like to use ASP.NET WebApi inside a SharePoint 2013 farm solution.
I know that it is not supported out of the box, but I found SignalR can be launched using a simple HttpModule , so I was wondering if a similar application could be used.
Thanks in advance, Rich
UPDATE June 2013
I did the work by processing the HTTP module specified in the specified message:
config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "kms2013/api/{controller}/{action}", defaults: new { } ); config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always; config.Services.Replace(typeof(IAssembliesResolver), new SPAssemblyResolver()); HostingEnvironment.RegisterVirtualPathProvider(new WebAPIVirtualPathProvider());
SPAssemblyResolver
public class SPAssemblyResolver : IAssembliesResolver { public ICollection<Assembly> GetAssemblies() { return new List<Assembly> { Assembly.GetExecutingAssembly() }; } }
WebAPIVirtualPathProvider
Same as SignalRVirtualPathProvider shown in the message.
NEW ISSUE
The only problem with this approach is that ScriptResource.axd and WebResource.axd now break when SP refers to them on the page. I tried to add an ignore route:
RouteTable.Routes.Add(new Route("{resource}.axd", new StopRoutingHandler()));
But I keep getting 401 Unauthorized. Removing the module fixes the error, so I think we are still missing one last piece of the puzzle.
source share