Bold BI®Unlock stunning dashboards with Bold BI®: 35+ widgets, 150+ data sources, AI agent & more. Try it for free!
Greetings,
I have an app that renders SSRS reports for the internet users, secured by Azure authentication tokens. The asp.net page has the report names hardcoded in its .cs file, not accessible after compiling the app.
I have been searching for ways to define a variable somewhere in a view that is editable from IIS (_ViewStart), for instance, assign a value to it and use it in the .aspx page on runtime
Something like:
The variable in _ViewStart view:
@{
public static string report = "reportname";
}
must be available in the .cs file below (in bold):
ssrs_report.aspx
ssrs_report.aspx.cs
Any ideas are appreciated. I'd like to avoid recompiling the app every time developers want to point it to a different report
Change the Report path dynamically in Report viewer using setmodel.
Index.cshtml
Reports are in Resource folder.
|
Thanks Manoranjan, for the great suggestion,
I am having trouble downloading all the required libraries for some reason. It could be our corporate network, will try it at home.
From what I see, you have a button on the site that controls the variable. All I need is to open the Index page in Notepad from IIS, change the repotname variables and click Save. The change should repoint the reportviewer to render a different SSRS report.
I just need something for an administrator to control, not a user. The variable should be visible within the code only
Greetings,
I have managed to solve it by utilizing the hiddenfield control.
In every .aspx file, add the line, specifying the HiddenFieldID (a string) and report path in "Value":
<asp:HiddenField ID="reportid" Value="/Reports/reportname" runat="server"></asp:HiddenField>
In respective aspx.cs file, reference the hidden field's value as:
string reportname = Convert.ToString(reportid.Value)
Now, after compiling the app and deploying it to IIS, I can change the Value without recompiling
Hi Polaro,
Thanks for the update.
If you have any other queries. Please create a new ticket from the below site. We were always happy to assist you.
https://support.boldreports.com/
Regards,
Manoranjan R
Hii
To avoid hardcoding report names and allow for dynamic configuration without recompiling the app, you can consider using a configuration file or a database to store the report names. Here's an approach you can take:
Create a configuration file or a database table to store the report names. This will allow developers or administrators to modify the report name without touching the code.
In your ASP.NET application, retrieve the report name from the configuration file or the database during runtime. You can use a configuration provider or a database connection to fetch the value.
Assign the retrieved report name to a variable or property in your ASP.NET application, which can then be accessed in your .aspx page and .cs file.
For example, using a configuration file approach:
Create a configuration file, such as appsettings.json, with the report name:
json
Copy code
{
"ReportSettings": {
"ReportName": "reportname"
}
}
In your ASP.NET application, add the configuration file and configure the app to read from it during startup:
csharp
Copy code
// In your Startup.cs file or similar
public void ConfigureServices(IServiceCollection services)
{
// Other configurations...
// Add configuration file support
services.Configure<ReportSettings>(Configuration.GetSection("ReportSettings"));
}
Create a class to represent the report settings, which will be used to retrieve the report name:
csharp
Copy code
public class ReportSettings
{
public string ReportName { get; set; }
}
In your ASPX code-behind file (ssrs_report.aspx.cs), access the report name using the injected configuration:
csharp
Copy code
using Microsoft.Extensions.Options;
public partial class ssrs_report : System.Web.UI.Page
{
private readonly ReportSettings _reportSettings;
public ssrs_report(IOptions<ReportSettings> reportSettings)
{
_reportSettings = reportSettings.Value;
}
protected void Page_Load(object sender, EventArgs e)
{
// Access the report name
string reportName = _reportSettings.ReportName;
// Other logic...
}
}
By utilizing a configuration file or a database, you can modify the report name without recompiling the application. Developers or administrators can update the configuration, and the application will dynamically pick up the changes during runtime.
If you want to hire professional azure developers you can visit our websitehttps://codestoresolutions.com/hire-azure-developer/
Dear Customer,
Thanks for the suggestion.
If you have any other queries. Please create a new ticket using your account using the below link. We are always happy to assist you.
https://support.boldreports.com/support/tickets
Regards,
Arumugasami M