我最近和大约一个小时前一样,尝试在我的 MVC 应用程序中实现 DoddleReports 功能。
非常肯定我按照文档到了 T。但是,当我输入我的 URL 时,它给了我一个 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);
}
}
}
路由器配置:
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!)。我在使用 MVC 配置Doddle的文档中阅读了一条评论,并替换了代码。(但它也不适用于自动生成的代码)。我还没有喜欢定制任何东西,因为我只是想让它首先工作!
那么,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'.