使用 ASP.NET MVC 配置 Telerik 报告
Configure Telerik Reporting with ASP.NET MVC
我正在关注这篇关于如何在 ASP.NET MVC 5 和 .NET 4.6.1 上配置 Telerik 报告的文章 Using HTML5 ASP.NET MVC Report Viewer in a web application then Telerik Reporting REST Web API to Web Application
我不能做的一件事是注册路由
如果我这样做,我会收到以下错误。我认为它与其他一些路线冲突,不确定它在哪里......
我尝试注释掉 MVC 路由注册,这也给出了同样的错误
//RouteConfig.RegisterRoutes(RouteTable.Routes);
A route named 'Resources' is already in the route collection. Route
names must be unique. Parameter name: name
所以当我 POST 调用以下 URL 时没有注册路由,我得到了很好的回应。
但是如果我尝试根据文档验证报告,我会收到以下错误
非常感谢任何帮助。
更新
路线问题已解决。删除了 WebApiConfig 初始化中的重复条目
当访问这个URLhttp://localhost:[portnumber]/api/reports/formats
以下错误仍未解决
{"message":"An error has occurred.","exceptionMessage":"The type
initializer for
'Telerik.Reporting.Processing.RenderingExtensionManager' threw an
exception.","exceptionType":"System.TypeInitializationException","stackTrace":"
at
Telerik.Reporting.Services.Engine.ReportEngine.ListRenderingExtensions()\r\n
at
Telerik.Reporting.Services.WebApi.ReportsControllerBase.GetDocumentFormats()\r\n
at lambda_method(Closure , Object , Object[] )\r\n at
System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_2.b__2(Object
instance, Object[] methodParameters)\r\n at
System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object
instance, Object[] arguments)\r\n at
System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext
controllerContext, IDictionary`2 arguments, CancellationToken
cancellationToken)\r\n--- End of stack trace from previous location
where exception was thrown ---\r\n at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Web.Http.Controllers.ApiControllerActionInvoker.d__1.MoveNext()\r\n---
End of stack trace from previous location where exception was thrown
---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Web.Http.Controllers.ActionFilterResult.d__5.MoveNext()\r\n---
End of stack trace from previous location where exception was thrown
---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Web.Http.Controllers.ExceptionFilterResult.d__6.MoveNext()"}
如果您确定以下行不会在 Application_Start
中出现两次,则进入 bin folder of project
、delete
所有 DLL
文件,因为如果您的旧 assemblies
仍然是其中的一部分,您可能仍然会得到 duplicate routes
。然后 rebuild
project
这将解决这个问题,
我在 web.config 中有这个部分,我删除了它并且效果很好
<section name="Telerik.Reporting" type="Telerik.Reporting.Configuration.ReportingConfigurationSection, Telerik.Reporting, Version=12.2.18.1129, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" allowLocation="true" allowDefinition="Everywhere" />
我正在关注这篇关于如何在 ASP.NET MVC 5 和 .NET 4.6.1 上配置 Telerik 报告的文章 Using HTML5 ASP.NET MVC Report Viewer in a web application then Telerik Reporting REST Web API to Web Application
我不能做的一件事是注册路由
如果我这样做,我会收到以下错误。我认为它与其他一些路线冲突,不确定它在哪里......
我尝试注释掉 MVC 路由注册,这也给出了同样的错误
//RouteConfig.RegisterRoutes(RouteTable.Routes);
A route named 'Resources' is already in the route collection. Route names must be unique. Parameter name: name
所以当我 POST 调用以下 URL 时没有注册路由,我得到了很好的回应。
但是如果我尝试根据文档验证报告,我会收到以下错误
更新
路线问题已解决。删除了 WebApiConfig 初始化中的重复条目
当访问这个URLhttp://localhost:[portnumber]/api/reports/formats 以下错误仍未解决
{"message":"An error has occurred.","exceptionMessage":"The type initializer for 'Telerik.Reporting.Processing.RenderingExtensionManager' threw an exception.","exceptionType":"System.TypeInitializationException","stackTrace":" at Telerik.Reporting.Services.Engine.ReportEngine.ListRenderingExtensions()\r\n at Telerik.Reporting.Services.WebApi.ReportsControllerBase.GetDocumentFormats()\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_2.b__2(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ExceptionFilterResult.d__6.MoveNext()"}
如果您确定以下行不会在 Application_Start
中出现两次,则进入 bin folder of project
、delete
所有 DLL
文件,因为如果您的旧 assemblies
仍然是其中的一部分,您可能仍然会得到 duplicate routes
。然后 rebuild
project
这将解决这个问题,
我在 web.config 中有这个部分,我删除了它并且效果很好
<section name="Telerik.Reporting" type="Telerik.Reporting.Configuration.ReportingConfigurationSection, Telerik.Reporting, Version=12.2.18.1129, Culture=neutral, PublicKeyToken=a9d7983dfcc261be" allowLocation="true" allowDefinition="Everywhere" />