public
class
Startup
{
private readonly IConfigurationRoot _appConfiguration;
public Startup(IHostingEnvironment env)
{
_appConfiguration = ();
}
public
IServiceProvider ConfigureServices(IServiceCollection services)
{
//Configure DbContext
<SCWebApiDbContext>(options =>
{
(, );
});
(options =>
{
(
new
AutoValidateAntiforgeryTokenAttribute());
});
// Swagger - Enable this line and the related lines in Configure method to enable swagger UI
(options =>
{
("v1", new Info { Title = "SC WebApi", Version = "v1" });
((docName, description) => true);
});
//Configure Abp and Dependency Injection
return
<SCWebApiWebModule>(options =>
{
//Configure Log4Net logging
<LoggingFacility>(
f => f.UseAbpLog4Net().WithConfig(
""
)
);
});
}
public
void
Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
();
//Initializes ABP framework.
if
(())
{
();
();
}
else
{
(
"/Error"
);
}
();
(routes =>
{
(
name:
"defaultWithArea"
,
template:
"{area}/{controller=Home}/{action=Index}/{id?}"
);
(
name:
"default"
,
template:
"{controller=Home}/{action=Index}/{id?}"
);
});
// Enable middleware to serve generated Swagger as a JSON endpoint
();
// Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
(options =>
{
(_appConfiguration["App:ServerRootAddress"] + "/swagger/v1/", "SC API V1");
= () => ()
.GetManifestResourceStream("");
}); // URL: /swagger
}
}