我最近在大約一個小時前嘗試將DoddleReports功能實現到我的MVC應用程序中。MVC DoddleReports 404 Not Found
非常積極我跟隨了文檔到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);
}
}
}
的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安裝輕而易舉 - 它也自動輸入在web.config中(未在web.config中所需要的東西查看文件夾!)。我在用MVC配置Doddle的文檔中閱讀了註釋right here,並替換了代碼。 (但它也不適用於自動生成的代碼)。我沒有想到定製任何東西,因爲我只是想讓它工作第一!
那麼,404頁面怎麼會出現?它使我看起來是與路由的東西,但我不確定具體是什麼。
任何幫助,非常感謝!
我在調試模式下使用它 - 所以也許這可能是一個原因?這是我使用的鏈接:
編輯*上傳到我的網站,仍然給出了一個404
http://localhost:2530/reports/OrganizationReport.xls
EDIT 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'.
謝謝 - 這有所幫助。 'var matrix = from db in db.Organizations select d;' 當我將此代碼更改爲'd.OrganizationID'時,頁面會加載但它是空白的。當我剛剛拿到'select d;'這個頁面就在加載時。我還刪除了RouteConfig中的「忽略路由」行。 – cfisher
我已完全複製來自示例DoddleReport的產品存儲庫和其他關聯項目。當我添加一個擴展時它仍然給我一個404錯誤。如果沒有擴展,它可以簡單地將表格加載到瀏覽器中。 – cfisher
我abbandoned抄報告,開發該解決方案:http://www.manik-software.co.uk/blog/post/Export-to-Excel-xlsx-from-ASPNET-MVC.aspx 在開始有很多的代碼,但是在您可以輕鬆地腳手架並重新使用查看操作 – fiorebat