我最近在大约一个小时前尝试将DoddleReports功能实现到我的MVC应用程序中。
非常积极的我跟着文件到T.但是,当我去输入我的网址时,它给了我一个404找不到。我通过NuGet安装了软件包,我只需要Excel,所以我添加了OpenXML(以及依赖项)。
我的控制器:
using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using VAGTC.Models;
using VAGTC.ViewModels;
using VAGTC.Helpers;
using DoddleReport.Web;
using DoddleReport;
namespace VAGTC.Controllers
{
public class reportsController : Controller
{
//
// GET: /Excel/
VAGTCEntities db = new VAGTCEntities();
public ActionResult Index()
{
return View();
}
public ReportResult OrganizationReport()
{
var matrix = from d in db.Organizations
select d;
var report = new Report(matrix.ToReportSource());
return new ReportResult(report);
}
}
}
RouterConfig:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using DoddleReport.Web;
namespace VAGTC
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapReportingRoute();
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Account", action = "Login", id = UrlParameter.Optional }
);
}
}
}
当我使用NuGet安装Doddle时 - 它还会自动输入web.config中所需的内容(而不是View文件夹中的web.config!)。我在用于配置Doddle with MVC的文档中阅读了评论right here并替换了代码。 (但它也不适用于自动生成的代码)。我并不喜欢定制任何东西,因为我只想让它先工作!
那么,404页面是怎么回事?它让我觉得它与路由有关,但我不确定具体是什么。
非常感谢任何帮助!
我在调试模式下使用它 - 所以也许这可能是一个原因?这是我正在使用的链接:
编辑*上传到我的网站,仍然提供404.
http://localhost:2530/reports/OrganizationReport.xls
编辑2 *
搞乱后,根据@fiorebat给出的论坛帖子改变一些事情。我在生成报告var report = new Report(matrix.ToReportSource());
后立即对其进行了调试,一旦返回报告就会出现此错误。
No Source Available
There is no source code available for the current location.
Call stack location:
DoddleReport.dll!DoddleReport.ReportBuilder.ToReportSource(System.Collections.IEnumerable source) Line 12
Source file information:
Locating source for 'c:\Users\Matt\Development\Projects\DoddleReport\src\DoddleReport\ReportBuilder.cs'. Checksum: MD5 {61 dc e5 8e 25 79 c2 94 c4 27 5b d0 d7 92 56 ae}
The file 'c:\Users\Matt\Development\Projects\DoddleReport\src\DoddleReport\ReportBuilder.cs' does not exist.
Looking in script documents for 'c:\Users\Matt\Development\Projects\DoddleReport\src\DoddleReport\ReportBuilder.cs'...
Looking in the projects for 'c:\Users\Matt\Development\Projects\DoddleReport\src\DoddleReport\ReportBuilder.cs'.
The file was not found in a project.
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\crt\src\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\crt\src\vccorlib\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\src\mfc\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\src\atl\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include'...
Looking in directory 'C:\'...
The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: c:\Users\Matt\Development\Projects\DoddleReport\src\DoddleReport\ReportBuilder.cs.
The debugger could not locate the source file 'c:\Users\Matt\Development\Projects\DoddleReport\src\DoddleReport\ReportBuilder.cs'.
答案 0 :(得分:2)
您需要在web配置下的system.webServer下添加此配置:
<modules runAllManagedModulesForAllRequests="true" ></modules>
我有同样的问题,报告没有扩展工程,我用“RouteDebuggin”调试路线,它正在工作。似乎DoodleReport插件没有调用正确的操作。