using
Microsoft.AspNetCore.Builder;
using
Microsoft.AspNetCore.Hosting;
using
Microsoft.Extensions.Configuration;
using
Microsoft.Extensions.DependencyInjection;
using
System.IO;
namespace
FlexViewerExplorer
{
public
class
Startup
{
public
Startup(IHostingEnvironment env)
{
var builder =
new
ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile(
"appsettings.json"
, optional:
true
, reloadOnChange:
true
)
.AddJsonFile($
"appsettings.{env.EnvironmentName}.json"
, optional:
true
);
Environment = env;
builder.AddEnvironmentVariables();
Configuration = builder.Build();
}
public
static
IHostingEnvironment Environment {
get
;
set
; }
public
IConfigurationRoot Configuration {
get
;
set
; }
public
void
ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddSession();
}
public
void
Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if
(env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseStaticFiles();
app.UseSession();
app.UseMvc(routes =>
{
routes.MapRoute(
name:
"default"
,
template:
"{controller}/{action}/{id?}"
,
defaults:
new
{ controller =
"FlexViewer"
, action =
"Intro"
});
});
app.UseStorageProviders().AddDiskStorage(
"PdfsRoot"
, Path.Combine(env.WebRootPath,
"PdfsRoot"
));
app.UseReportProviders().AddFlexReportDiskStorage(
"ReportsRoot"
, Path.Combine(env.WebRootPath,
"ReportsRoot"
));
var ssrsUrl = Configuration[
"AppSettings:SsrsUrl"
];
var ssrsUserName = Configuration[
"AppSettings:SsrsUserName"
];
var ssrsPassword = Configuration[
"AppSettings:SsrsPassword"
];
app.UseReportProviders().AddSsrsReportHost(
"c1ssrs"
, ssrsUrl,
new
System.Net.NetworkCredential(ssrsUserName, ssrsPassword));
}
}
}