Posted 5 November 2024, 10:54 pm EST - Updated 6 November 2024, 12:02 am EST
Hi,
when I tried to load report,
http://localhost:0000/InvoiceSystem/Home/InvoiceSystem/api/reporting/reports/Report2.rdlx/info 404 (Not Found)
this error occurs and the report didn’t load on screen.
I use ActiveReports .NET (VS 2022),
and my Program.cs file has
DirectoryInfo ReportsDirectory =
new DirectoryInfo(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? String.Empty, "ActiveReports"));
// Add services to the container.
builder.Services.AddLogging(config =>
{
// Disable the default logging configuration
config.ClearProviders();
// Enable logging for debug mode only
if (Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") == Environments.Development)
{
config.AddConsole();
}
})
.AddReportViewer()
.AddMvc(options => options.EnableEndpointRouting = false);
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
}
app.UseReportViewer(settings =>
{
settings.UseFileStore(ReportsDirectory);
});
this code, and in controller, I send data
[Area("InvoiceSystem")]
[Route("[area]/[controller]/[action]")]
public class HomeController : Controller
{
private static readonly string CurrentDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? System.String.Empty;
public static readonly DirectoryInfo ReportsDirectory = new DirectoryInfo(Path.Combine(CurrentDir, "ActiveReports"));
[HttpGet]
public ActionResult Index()
{
string[] validFileNames = { "Report2.rdlx" };
var reportsList = GetFileStoreReports(validFileNames);
var list = new ObjectResult(reportsList);
ViewData["list"] = list;
return View();
}
like this.
javascript code is here.
let viewer;
let reports = @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(ViewData["list"]));
window.onload = function () {
viewer = createViewer({
element: '#viewerContainer'
});
viewer.openReport("Report2.rdlx");
};
also if it needed, in project, this code include.
<ItemGroup>
<None Include="wwwroot\**\*.*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="ActiveReports\**\*.*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Do I need to set the path somewhere else, or should I create a folder in a specific location?