SharePoint 2013 and ASP.NET WebApi

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.

+6
source share
1 answer

Yes, the same approach should work.

Create an api web project and check out part of the application, and then follow my blog post that you have already pointed out.

Btw: Ask at sharepoint.stackexchange.com - maybe someone has a better solution.

+1
source

Source: https://habr.com/ru/post/944557/


All Articles