Click here to Skip to main content
15,868,016 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: How to use FCKeditorV2 instead of FreeTextBox ? Pin
jkirkerx16-Jan-20 7:34
professionaljkirkerx16-Jan-20 7:34 
Question.Net Core 2.2.4 - Getting IHostingEnvironment in Program.cs Main Pin
jkirkerx14-Jan-20 10:24
professionaljkirkerx14-Jan-20 10:24 
I know how to get it in Startup, but I wrote a class that seeds the database with values, and expanded it to write the product images to wwwroot from the database called SeedDatabase. I just need the wwwroot so I can write the images to the right place.

Guess I figured it out...
Amazing, had no idea this would work, well in development at least.
So I can request services from startup? That's my new question.
private static void SeedDatabase(IWebHost host, Settings appSettings, bool isDocker, string env)
{
    using (var scope = host.Services.CreateScope())
    {
        var services = scope.ServiceProvider;
        var logger = services.GetRequiredService<ILogger<Program>>();
        var environment = services.GetService<IHostingEnvironment>();
        logger.LogInformation("DbAuthConnection=" + appSettings.MongoDB.Connection);
        logger.LogInformation("DbAuthContainer=" + appSettings.MongoDB.Container);
        logger.LogInformation("Environment=" + env);

        try
        {
            DbInitializer.SeedData(appSettings, environment, isDocker);<br />
            logger.LogInformation("Seed DB Succeeded:" + DateTime.Now);

        }
        catch (Exception ex)
        {
            logger.LogError(ex, "Seed DB Failed on " + DateTime.Now + ":" + ex.Message);                    
        }
    }
}   
If it ain't broke don't fix it
Discover my world at jkirkerx.com

QuestionHtmlagilitypack -- I'm stuck Pin
Member 175325011-Jan-20 5:40
Member 175325011-Jan-20 5:40 
QuestionHow do I fix System.Net.Mail.SmtException: 'Cannot get IIS pickup directory' error? Pin
Member 1140330410-Jan-20 9:19
Member 1140330410-Jan-20 9:19 
AnswerRe: How do I fix System.Net.Mail.SmtException: 'Cannot get IIS pickup directory' error? Pin
Richard MacCutchan10-Jan-20 11:37
mveRichard MacCutchan10-Jan-20 11:37 
AnswerRe: How do I fix System.Net.Mail.SmtException: 'Cannot get IIS pickup directory' error? Pin
ZurdoDev11-Jan-20 9:03
professionalZurdoDev11-Jan-20 9:03 
QuestionHow do I fix 'object' does not contain a definition for 'Value'? Pin
Member 1140330410-Jan-20 8:27
Member 1140330410-Jan-20 8:27 
AnswerRe: How do I fix 'object' does not contain a definition for 'Value'? Pin
ZurdoDev10-Jan-20 9:09
professionalZurdoDev10-Jan-20 9:09 
QuestionWhy can't I login to the web even though the User and password are correct ? Pin
Member 24584679-Jan-20 21:43
Member 24584679-Jan-20 21:43 
AnswerRe: Why can't I login to the web even though the User and password are correct ? Pin
ZurdoDev10-Jan-20 1:00
professionalZurdoDev10-Jan-20 1:00 
GeneralRe: Why can't I login to the web even though the User and password are correct ? Pin
Member 245846714-Jan-20 16:19
Member 245846714-Jan-20 16:19 
GeneralRe: Why can't I login to the web even though the User and password are correct ? Pin
ZurdoDev14-Jan-20 16:52
professionalZurdoDev14-Jan-20 16:52 
AnswerRe: Why can't I login to the web even though the User and password are correct ? Pin
Richard Deeming10-Jan-20 2:32
mveRichard Deeming10-Jan-20 2:32 
GeneralRe: Why can't I login to the web even though the User and password are correct ? Pin
Member 245846714-Jan-20 16:24
Member 245846714-Jan-20 16:24 
GeneralRe: Why can't I login to the web even though the User and password are correct ? Pin
Richard Deeming15-Jan-20 0:25
mveRichard Deeming15-Jan-20 0:25 
GeneralRe: Why can't I login to the web even though the User and password are correct ? Pin
Member 245846716-Jan-20 20:23
Member 245846716-Jan-20 20:23 
GeneralRe: Why can't I login to the web even though the User and password are correct ? Pin
Richard Deeming17-Jan-20 0:30
mveRichard Deeming17-Jan-20 0:30 
QuestionHow do you have a DropDownList populated without default selected item? Pin
Member 114033049-Jan-20 6:07
Member 114033049-Jan-20 6:07 
AnswerRe: How do you have a DropDownList populated without default selected item? Pin
ZurdoDev9-Jan-20 6:40
professionalZurdoDev9-Jan-20 6:40 
GeneralRe: How do you have a DropDownList populated without default selected item? Pin
Member 114033049-Jan-20 6:56
Member 114033049-Jan-20 6:56 
GeneralRe: How do you have a DropDownList populated without default selected item? Pin
ZurdoDev9-Jan-20 7:59
professionalZurdoDev9-Jan-20 7:59 
GeneralRe: How do you have a DropDownList populated without default selected item? Pin
Mycroft Holmes9-Jan-20 10:14
professionalMycroft Holmes9-Jan-20 10:14 
QuestionHow to I make EmailButton_Click work? Pin
Member 114033048-Jan-20 4:59
Member 114033048-Jan-20 4:59 
AnswerRe: How to I make EmailButton_Click work? Pin
ZurdoDev8-Jan-20 5:21
professionalZurdoDev8-Jan-20 5:21 
AnswerRe: How to I make EmailButton_Click work? Pin
F-ES Sitecore8-Jan-20 5:45
professionalF-ES Sitecore8-Jan-20 5:45 

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.