Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix Local Debug SSO Tab with .NET 9 #13069

Merged
merged 4 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { CapabilityOptions, ProgrammingLanguage, QuestionNames } from "../../../
import { DefaultTemplateGenerator } from "./templateGenerator";
import { TemplateInfo } from "./templateInfo";
import { TemplateNames } from "./templateNames";
import { Generator } from "../generator";

// For the APS.NET server-side rendering tab
export class SsrTabGenerator extends DefaultTemplateGenerator {
Expand All @@ -27,11 +28,27 @@ export class SsrTabGenerator extends DefaultTemplateGenerator {
inputs: Inputs,
destinationPath: string
): Promise<Result<TemplateInfo[], FxError>> {
const appName = inputs[QuestionNames.AppName];
const language = inputs[QuestionNames.ProgrammingLanguage] as ProgrammingLanguage;
const safeProjectNameFromVS =
language === "csharp" ? inputs[QuestionNames.SafeProjectName] : undefined;
const isNet9 = inputs.targetFramework === "net9.0";
const replaceMap = {
...Generator.getDefaultVariables(
appName,
safeProjectNameFromVS,
inputs.targetFramework,
inputs.placeProjectFileInSolutionDir === "true"
),
Net9Framework: isNet9 ? "true" : "",
};

return Promise.resolve(
ok([
{
templateName: this.capabilities2TemplateNames[inputs.capabilities as string],
language: ProgrammingLanguage.CSharp,
replaceMap,
},
])
);
Expand Down
6 changes: 6 additions & 0 deletions templates/csharp/sso-tab-ssr/Program.cs.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ app.UseAntiforgery();
app.UseAuthentication();
app.UseAuthorization();

{{^Net9Framework}}
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
{{/Net9Framework}}
{{#Net9Framework}}
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode(o => o.ContentSecurityFrameAncestorsPolicy = "'self' *");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this also work in .net 8? If yes, let's make it consistent for both .net 9 and .net 8.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a new feature in .net9, this function was not available in .net8.

{{/Net9Framework}}

app.Run();
Loading