Dev / QA / Prod Settings

Here's my problem: I set up the email validation in my application so that I could use the reset password feature. It works fine locally, but when I deploy it to our QA server, I get a redirect to localhost:8000 upon clicking the link in the email.

My manager suggested researching how to use a separate appsettings.prod.json (for the moment, our pipeline for server deployment is called prod, even though it is in QA). I did. I created an appsettings.prod.json file, copied from appsettings.json, added my settings section, created a service class to pull it into the AuthController, and changed the redirect in both places in the AuthController to this.options.Value.HomePage (which is a string with the value of our QA URL).

Everything looks good in VS Code, and then I clicked Run in Radzen, and as I'm sure you knew halfway through reading my previous paragraph, it overwrote my code change in the AuthController. This is one of my major frustrations with Radzen. Two things:

  1. Where do I find a list of which files I'm allowed to change where the changes won't be overwritten?
  2. How does Radzen handle different variables for different environments, such as where to redirect to?

The safest bet is to assume that your changes will be overwritten.You should use the code generation ignore list to exclude certain files.

Radzen does not have its own way to do that. You can use the .NET built-in one though - through appsettings.json or the methods listed here.

Ok... Other than ignoring code generation on the AuthController, I don't see a way to make this work, since the AuthController has this hard-coded into it:

if (result.Succeeded)
{
   user.EmailConfirmed = true;
   return Redirect("http://localhost:8000");
}

Our build pipeline for CI is on TFS (using git), and the variables look like this:
image
With it set to Release for the BuildConfiguration, I would have expected a substitution to be made in the two redirect lines in AuthController.cs, but since it is hard coded, I assume that is why it doesn't happen? Admittedly, though, I don't know anything about how the CI works. I just push and merge and it goes.

To be honest localhost shouldn't appear at all. We replace it during production builds but I understand this won't work for you. We will update the generated code to just use Redirect("/"). As a temporary workaround you can use the code generation ignore list.

Ok, so if I understand you right, for now, I should put AuthController.cs on the ignore list, and change the redirect to ("/"), and then when you release an update for this, I can remove the file from the ignore list, and all will be well. Correct?

The new version released today will generate Redirect(“/”).

1 Like