在 Dnn v8 站点中找不到 Api >>> 续 2021 年 5 月 4 日与你同在将 2sxc 升级到 11.22.0 LTS

问题描述

我们有一个 Dnn 站点,我们将停用和替换。我们决定导出我们需要的客户端数据的一种简单方法是重新使用我们已经为另一个项目构建的 2sxc Api 工具。所以我们安装了最新版本的 2sxc (11.12.1),似乎一切正常。添加一个应用,准备好所有文件并开始测试。

无论我们做什么,api 都会出现 404 错误

是否有额外的配置或我们需要做的事情来让 Dnn v8 允许 URL 被路由?

我们尝试了长版和短版,但都没有运气。我们将设置移至 Dnn v9.08.01,它按预期工作。

/api/2sxc/app/appname/api/public/hello

/DesktopModules/2sxc/api/app/appname/api/public/hello

我们甚至从我们的代码切换到 the 2sxc basic WebApi Examples 中的演示,并且所有可能的路径变体(适用于 Dnn 9)都不适用于 Dnn 8。

知道我们缺少什么吗?

>>> 续 2021 年 5 月 4 日(与你同在)

将 2sxc 升级到 11.22.0 LTS

继续尝试各种事情。将文件(和类)从 api/PublicController.cs 重命名api/AppExtController.cs。使用新的 2sxc Api 工具进行测试。仍然没有运气。

终于上了服务器,在本地浏览器中再次尝试,终于吐出一个详细的——对我来说——令人惊讶的——错误

<ExceptionMessage>An error occurred when trying to create a controller of type 'AppExtController'. Make sure that the controller has a parameterless public constructor.</ExceptionMessage>

<InnerException>
<Message>An error has occurred.</Message>
<ExceptionMessage>Unable to resolve AppExtController IsResolutionCall from Container with ambient ScopeContext DnnSharp.DryIoc.AsyncExecutionFlowScopeContext with Scope {Name=~WebRequestScopeName} with Rules with {SelectLastRegisteredFactory} with FactorySelector=SelectLastRegisteredFactory with Made={FactoryMethod=ConstructorWithResolvableArguments,PropertiesAndFields=<custom>,ParameterSelector=<custom>} Where no service registrations found and no dynamic registrations found in 0 of Rules.DynamicServiceProviders and nothing found in 1 of Rules.UnkNownServiceResolvers</ExceptionMessage>

<ExceptionType>DnnSharp.DryIoc.ContainerException</ExceptionType>

<StackTrace> at DnnSharp.DryIoc.Throw.It(Int32 error,Object arg0,Object arg1,Object arg2,Object arg3) at DnnSharp.DryIoc.Container.TryThrowUnabletoResolve(Request request) at DnnSharp.DryIoc.Container.DnnSharp.DryIoc.IContainer.ResolveFactory(Request request) at DnnSharp.DryIoc.Container.ResolveAndCacheFactoryDelegate(Type serviceType,IfUnresolved ifUnresolved) at DnnSharp.Common2.IoC.WebApi.DnnSharpDependencyScope.GetService(Type serviceType) at System.Web.Http.dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(HttpRequestMessage request,Type controllerType,Func`1& activator) at System.Web.Http.dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request,HttpControllerDescriptor controllerDescriptor,Type controllerType)</StackTrace>
</InnerException>

如果你错过了,上面要注意的关键是 DnnSharp.DryIoc 正在抛出异常。

我意识到这可能意味着它不是 2sxc 问题。但我确实安装了 DnnSharp 的 ActionForm。我不知道任何 API 选项或设置。

有什么方法可以弄清楚为什么使用路由或处理?我应该在哪里解决这个问题?

此外,您在下面提到了“DNN 中的配置错误(缺少主域...” - 您能否提供更多有关我需要检查的相关信息的详细信息?我确实检查过,DefaultPortalAlias 匹配站点的设置。它是唯一的门户 (0),没有语言。

站点设置、站点行为、站点别名与主域具有相同的域,站点别名映射模式为重定向

Servers/System Info/Web,Site Url 也显示相同的域。

其中有任何相关或在起作用吗?他们似乎都对齐了。

解决方法

我们最终从站点中删除了 ActionForm,API 开始按预期工作。所以它与依赖注入冲突有关。我本可以对 ActionForm 进行付费升级以获得修复它的更新版本(我们使用的是 v5.1.54),但是只有 1 个联系表,所以我们用其他东西替换了它,删除了 AF 并且问题消失了.