Click here to Skip to main content
15,882,114 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Display a message when Radio Button is not selected Pin
Vincent Maverick Durano10-Apr-19 11:03
professionalVincent Maverick Durano10-Apr-19 11:03 
QuestionMembership section of VS2017 Web config Pin
Member 87616678-Apr-19 2:02
Member 87616678-Apr-19 2:02 
Questionwhy's the error not found namespace or class ? Pin
Member 24584676-Apr-19 20:43
Member 24584676-Apr-19 20:43 
AnswerRe: why's the error not found namespace or class ? Pin
OriginalGriff7-Apr-19 20:07
mveOriginalGriff7-Apr-19 20:07 
GeneralRe: why's the error not found namespace or class ? Pin
Member 245846723-Apr-19 16:39
Member 245846723-Apr-19 16:39 
GeneralRe: why's the error not found namespace or class ? Pin
Mycroft Holmes23-Apr-19 19:18
professionalMycroft Holmes23-Apr-19 19:18 
GeneralRe: why's the error not found namespace or class ? Pin
OriginalGriff23-Apr-19 20:03
mveOriginalGriff23-Apr-19 20:03 
Question.Net Core 2.2.3 with Angular, preparing for Docker Container Deployment with MongoDB running in a container, all Linux going crazy Pin
jkirkerx5-Apr-19 12:27
professionaljkirkerx5-Apr-19 12:27 
This is my learning project in which I wrapped Angular 7 in .Net Core. I'm in the process of preparing the project to run in a Docker Container and connect to MongoDB that runs in a Docker Container. So I had rewrite the project so it's knows if it's running in a Docker container or just running in IIS, and for development and production environments.

Accomplishments:
Figured out how to edit the Dockerfile, and inject 2 PFX files into the .Net Core container for portable SSL.
Figured out the port mapping on 5000, 5001, 44367, and how not to load Kestrel for development, yet load it for production.
I got my Docker-Compose dialed in to create MongoDB V4.08, the static data volume, bridge network to talk to the .Net Core container.
Created a a dual appSettings.json for production and development.
Got the user secrets going, but haven't figured out the Kestrel part yet.

So far so good. But I'm getting some crazy erratic results ...
It's like it's stuck in a build and won't update.
The project always displays data from a mongo database on on another server from previous builds.
I can't get the connection string to work with the user name and password under SHA-1 using the C# Mongo Drivers, but it works without credentials, I think that's my problem.
I go to debug to confirm that it detected the Docker Container, but I can't hit the break-point, yet project.dll symbols are loaded.

It's just gotten to the point where I'm going around in circles, and need to confirm some code before I change good code.
On the data, I can Roto3T into each Mongo and see the data I created which is all different.

In startup, I read the appSettings.development.json file and add 1 more option called IsContained, which is what I was trying to hit in the break-point. If I set this extra option here, I should be able to read it in my DBContext?
What I did was try and read the Environment Variable since I wasn't able to confirm the option. But would SETTINGS contain that option?
// Configure our Program Settings to replace Web.Config
services.Configure<Settings>(Configuration.GetSection("Settings"));
services.Configure<Settings>(
    options =>
    {
        options.MongoDB.Connection = Configuration.GetSection("MongoDB:Connection").Value;
        options.MongoDB.Database = Configuration.GetSection("MongoDB:Database").Value;
        options.MongoDB.Container = Configuration.GetSection("MongoDB.Container").Value;
        options.MongoDB.IsContained = Configuration["DOTNET_RUNNING_IN_CONTAINER"] != null;
    }
);
private readonly IMongoDatabase _database = null;
public DbContext(IOptions<<code>Settings</code>> appSettings)
{
    // 2nd method that I can't prove works
    bool.TryParse(Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER"), out var isDocker);
    Console.Write("DBContext IsDocker = " + isDocker);

    // Choose either the regular conn string to connect to Mongo as a Win Service, or Linux with SHA-1
    var client = new MongoClient(isDocker ? appSettings.Value.MongoDB.Container : appSettings.Value.MongoDB.Connection);
    _database = client.GetDatabase(appSettings.Value.MongoDB.Database);
}

This is for a sanity check. I had to rewrite this to accommodate containers and my portable SSL certifcates. So if I use Kubernetes in the future, more .Net app containers can be spawned with SSL self contained. Online research says I need to use Kestrel for this and bind the port with the certificate. This crashed in development when trying to use the localhost certificate but now it works using the dev-certs certificate that is registered. Haven't tried it yet in Production using a real certificate, that comes when I fix the other issues first. But I will have more Kestrel questions soon. Any help or pointers on this would be appreciated.
public static void Main(string[] args)
{
    var config = new ConfigurationBuilder()
        .SetBasePath(Directory.GetCurrentDirectory())
        .AddJsonFile("secrets.json", optional: true, reloadOnChange: true)
        .AddJsonFile($"appSettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", optional: false, reloadOnChange: true)
        .AddJsonFile($"certificate.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT")}.json", optional: false, reloadOnChange: true)
        .Build();

<pre>
var appSettings = config.GetSection("Settings").Get<Settings>();
var dbSecrets = config.GetSection("Database").Get<DbSecrets>();
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
bool.TryParse(Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER"), out var isDocker);
var host = CreateWebHostBuilder(args).Build();

if (env == "Production" && isDocker)

{
var certificateSettings = config.GetSection("certificateSettings");
var certificateFileName = certificateSettings.GetValue<string>("filename");
var certificatePassword = certificateSettings.GetValue<string>("password");
var certificate = new X509Certificate2(certificateFileName, certificatePassword);
var builder = new WebHostBuilder()
.UseKestrel(
options =>
{
options.AddServerHeader = false;
options.Listen(IPAddress.Loopback, 44367, listenOptions =>
{
listenOptions.UseHttps(certificate);
});
}
)
.UseConfiguration(config)
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<startup>()
.Build();

builder.Run();
}

host.Run();
}


Note:
Visual Studio does an OK job in getting your project into Docker for testing, but left out so many factors.
And the Internet is jammed pack with outdated information on the topic.

All the Angular stuff seem to work fine, and I think it's all .Net Core related.
If it ain't broke don't fix it
Discover my world at jkirkerx.com

AnswerRe: .Net Core 2.2.3 with Angular, preparing for Docker Container Deployment with MongoDB running in a container, all Linux going crazy Pin
jkirkerx7-Apr-19 11:50
professionaljkirkerx7-Apr-19 11:50 
AnswerFinally figured it out! Pin
jkirkerx11-Apr-19 12:47
professionaljkirkerx11-Apr-19 12:47 
QuestionMy div repeated 3 times if format its css if use form runas server Pin
Ashraf Khalifah4-Apr-19 23:25
Ashraf Khalifah4-Apr-19 23:25 
AnswerRe: My div repeated 3 times if format its css if use form runas server Pin
User 418025411-Apr-19 8:48
User 418025411-Apr-19 8:48 
Question(SOLVED) WHy is my image not displaying on a certain page? Pin
samflex3-Apr-19 6:28
samflex3-Apr-19 6:28 
AnswerRe: WHy is my image not displaying on a certain page? Pin
Richard Deeming3-Apr-19 7:48
mveRichard Deeming3-Apr-19 7:48 
GeneralRe: WHy is my image not displaying on a certain page? Pin
samflex3-Apr-19 9:56
samflex3-Apr-19 9:56 
GeneralRe: WHy is my image not displaying on a certain page? Pin
Richard Deeming3-Apr-19 22:00
mveRichard Deeming3-Apr-19 22:00 
GeneralRe: WHy is my image not displaying on a certain page? Pin
samflex4-Apr-19 5:59
samflex4-Apr-19 5:59 
QuestionLoad event fires twice and QueryString becomes empty!! Pin
pldelosrios2-Apr-19 3:41
pldelosrios2-Apr-19 3:41 
SuggestionRe: Load event fires twice and QueryString becomes empty!! Pin
Richard Deeming2-Apr-19 8:16
mveRichard Deeming2-Apr-19 8:16 
QuestionError 550 Permission denied: Windows Server 7 FTP Server ? Pin
Member 245846722-Mar-19 18:13
Member 245846722-Mar-19 18:13 
GeneralRe: Error 550 Permission denied: Windows Server 7 FTP Server ? Pin
Richard MacCutchan22-Mar-19 23:10
mveRichard MacCutchan22-Mar-19 23:10 
GeneralRe: Error 550 Permission denied: Windows Server 7 FTP Server ? Pin
Member 245846724-Mar-19 18:35
Member 245846724-Mar-19 18:35 
QuestionWant to find out differences between two branches (local or remote) in Git Pin
simpledeveloper22-Mar-19 20:47
simpledeveloper22-Mar-19 20:47 
AnswerRe: Want to find out differences between two branches (local or remote) in Git Pin
Richard MacCutchan23-Mar-19 2:29
mveRichard MacCutchan23-Mar-19 2:29 
Questionvisual studio for mac, Unexpected character '�' (CS1056) Pin
Member 1182460318-Mar-19 16:25
Member 1182460318-Mar-19 16:25 

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.