Click here to Skip to main content
15,890,438 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: .Net Core 2.1, Get the Environment to seed a database so I can get the path Pin
Richard Deeming28-Jun-18 10:26
mveRichard Deeming28-Jun-18 10:26 
GeneralRe: .Net Core 2.1, Get the Environment to seed a database so I can get the path Pin
jkirkerx28-Jun-18 11:56
professionaljkirkerx28-Jun-18 11:56 
QuestionSenior MVC Full Stack Developer Job Postings with Angular Experience Pin
jkirkerx27-Jun-18 8:42
professionaljkirkerx27-Jun-18 8:42 
AnswerRe: Senior MVC Full Stack Developer Job Postings with Angular Experience Pin
F-ES Sitecore27-Jun-18 23:44
professionalF-ES Sitecore27-Jun-18 23:44 
GeneralRe: Senior MVC Full Stack Developer Job Postings with Angular Experience Pin
jkirkerx28-Jun-18 6:50
professionaljkirkerx28-Jun-18 6:50 
AnswerRe: Senior MVC Full Stack Developer Job Postings with Angular Experience Pin
Richard Deeming28-Jun-18 1:03
mveRichard Deeming28-Jun-18 1:03 
GeneralRe: Senior MVC Full Stack Developer Job Postings with Angular Experience Pin
jkirkerx28-Jun-18 6:55
professionaljkirkerx28-Jun-18 6:55 
Question.net Core 2.1, Startup.cs, IConfiguration vs IHostingEnviroment Pin
jkirkerx27-Jun-18 7:14
professionaljkirkerx27-Jun-18 7:14 
Well I have two functions called Startup and I just need one I think. One was stock called Startup(IConfiguration configuration) that gets called from Program.cs I think, and the other I added from examples in how to read the appsettings.json file called Startup(IHostingEnviroment env) and how to initialize the database.

So basically being so new here, I must of confused versions such as core 1 vs core 2
I would assume the first is correct.
public IConfiguration Configuration { get; }
public Startup(IConfiguration configuration)
{
   Configuration = configuration;            
}

And the 2nd one is incorrect for core 2.1
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)
        .AddEnvironmentVariables();

    using (var client = new IndigoDBContext())
    {
        client.Database.EnsureCreated();
        client.Database.Migrate();
    }

    Configuration = builder.Build();            
}

But I don't see another place that has the environment except for Configure. Maybe the 2nd code goes there.
I'm trying to get my database created, and set migration.
Question is: I suspect I'm on the wrong track here, and I need a little help getting squared up on this. I probably have duplicates of or version overlaps here.

This is my ConfigureServices Function, I'm pretty sure I have this right
public void ConfigureServices(IServiceCollection services)
{
    services.Configure<CookiePolicyOptions>(options =>
    {
        // This lambda determines whether user consent for non-essential cookies is needed for a given request.
        options.CheckConsentNeeded = context => true;
        options.MinimumSameSitePolicy = SameSiteMode.None;
    });

<pre>
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
    .AddApplicationPart(typeof(ErrorController).GetTypeInfo().Assembly);

services.AddHttpContextAccessor();
services.Configure<AppConfiguration>(Configuration.GetSection("AppConfiguration"));
services.Configure<SmtpConfig>(Configuration.GetSection("SmtpConnection"));
services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.TryAddSingleton<IActionContextAccessor, ActionContextAccessor>();    

services.AddEntityFrameworkSqlite().AddDbContext<indigodbcontext>();
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie();
services.AddHttpContextAccessor();
}

If it ain't broke don't fix it
Discover my world at jkirkerx.com

AnswerRe: .net Core 2.1, Startup.cs, IConfiguration vs IHostingEnviroment Pin
Richard Deeming27-Jun-18 7:45
mveRichard Deeming27-Jun-18 7:45 
GeneralRe: .net Core 2.1, Startup.cs, IConfiguration vs IHostingEnviroment [solved] Pin
jkirkerx27-Jun-18 8:08
professionaljkirkerx27-Jun-18 8:08 
QuestionBody Tag, Razor and AngularJS workaround or better idea for body tag cannot have c# in it. Pin
jkirkerx27-Jun-18 6:26
professionaljkirkerx27-Jun-18 6:26 
AnswerRe: Body Tag, Razor and AngularJS workaround or better idea for body tag cannot have c# in it. Pin
Richard Deeming27-Jun-18 7:13
mveRichard Deeming27-Jun-18 7:13 
GeneralRe: Body Tag, Razor and AngularJS workaround or better idea for body tag cannot have c# in it. Pin
jkirkerx27-Jun-18 8:13
professionaljkirkerx27-Jun-18 8:13 
GeneralRe: Body Tag, Razor and AngularJS workaround or better idea for body tag cannot have c# in it. Pin
Richard Deeming27-Jun-18 8:18
mveRichard Deeming27-Jun-18 8:18 
Question.Net Core 2.1, DI and System.Web in a separate 2.1 Project Pin
jkirkerx25-Jun-18 12:14
professionaljkirkerx25-Jun-18 12:14 
AnswerRe: .Net Core 2.1, DI and System.Web in a separate 2.1 Project Pin
F-ES Sitecore26-Jun-18 0:03
professionalF-ES Sitecore26-Jun-18 0:03 
GeneralRe: .Net Core 2.1, DI and System.Web in a separate 2.1 Project Pin
jkirkerx26-Jun-18 6:33
professionaljkirkerx26-Jun-18 6:33 
AnswerRe: .Net Core 2.1, DI and System.Web in a separate 2.1 Project Pin
Richard Deeming26-Jun-18 1:37
mveRichard Deeming26-Jun-18 1:37 
GeneralRe: .Net Core 2.1, DI and System.Web in a separate 2.1 Project Pin
jkirkerx26-Jun-18 6:35
professionaljkirkerx26-Jun-18 6:35 
QuestionImages are not exporting to pdf using jspdf.debug.js Pin
Member 1370125121-Jun-18 23:05
Member 1370125121-Jun-18 23:05 
QuestionReactJS.Net - Server side rendering works in development, but not on my production server Pin
jkirkerx14-Jun-18 11:36
professionaljkirkerx14-Jun-18 11:36 
Answer[solved] Pin
jkirkerx18-Jun-18 9:52
professionaljkirkerx18-Jun-18 9:52 
QuestionBlurry Pdf Output while uisng Html2pdf.bundle.js Pin
Member 1370125113-Jun-18 19:35
Member 1370125113-Jun-18 19:35 
AnswerRe: Blurry Pdf Output while uisng Html2pdf.bundle.js Pin
Nathan Minier14-Jun-18 16:46
professionalNathan Minier14-Jun-18 16:46 
QuestionConversion of HTML to PDF Using JsPdf Pin
Member 1370125111-Jun-18 20:08
Member 1370125111-Jun-18 20:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.