【发布时间】:2021-04-16 15:19:40
【问题描述】:
我们有一个 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 也显示相同的域。
这些是否相关或正在发挥作用?它们似乎都对齐。
【问题讨论】:
-
我没有一个快速的答案。我的猜测是 DNN 中的一些错误配置(缺少主域,域有语言等)。我建议您尝试安装 2sxc 11.20(刚刚发布),它具有调用 API 的帮助对话框。不知道这是否有帮助...
-
在原始问题中查看上面的更新...
-
这太疯狂了。以前从未见过。但从消息的性质来看,DnnSharp 似乎有一个 Ioc(控制反转 = 依赖注入)系统。这通常是一个好主意(2sxc 从 2015 年开始使用 DI),但它不应该渗透到其他代码中。我不得不假设这个 DryIoc 引起了问题,你需要和 DnnSharp 谈谈。
标签: asp.net-web-api dotnetnuke 2sxc