我想在SharePoint 2013服務器場解決方案中使用ASP.NET WebApi。SharePoint 2013和ASP.NET WebApi
我知道它並不支持開箱即用,但是我找到了SignalR can be run by means of a simple HttpModule,所以我想知道是否可以使用類似的應用程序。
由於提前, 豐富
UPDATE 2013年6月
製造它通過再加工中所提到的後顯示的HTTP模塊的工作:
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
同在後示出SignalRVirtualPathProvider。
新發行
這種方法唯一的問題是的ScriptResource.axd和WebResource.axd的 SP時引用它們的頁面現在打破。我嘗試添加一個忽略路線:
RouteTable.Routes.Add(new Route("{resource}.axd", new StopRoutingHandler()));
但我不斷收到401未授權。刪除模塊清除了錯誤,所以我想我們仍然缺少最後一塊難題。
我假設您必須調整虛擬路徑提供程序,請參閱此處的示例:https://spsignalr.codeplex.com/SourceControl/latest#MaxMelcher.SPSignalR/SignalRVirtualPathProvider.cs – 2013-06-27 10:46:39
很好,您建議的VPP實施陷阱失蹤案件和一切工作現在。 以前,_DirectoryExists_在缺少_virtualDir.Contains(「my/api/path」)_時產生各種錯誤,範圍從SharePoint JS錯誤,破碎的搜索等。 – user2363245 2013-07-02 10:07:32
我試圖做同樣的事情,米幾乎在那裏,但我得到一個錯誤,因爲它找不到控制器。只部署webapi項目,它工作正常,但在SP內部打破。你有什麼建議嗎? – 2014-12-15 12:03:34