Skip to content

Commit

Permalink
fix: Fix Local Debug SSO Tab with .NET 9 (#13069)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yimin-Jin authored Jan 20, 2025
1 parent fbb1562 commit 5922727
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
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,25 @@ export class SsrTabGenerator extends DefaultTemplateGenerator {
inputs: Inputs,
destinationPath: string
): Promise<Result<TemplateInfo[], FxError>> {
const appName = inputs[QuestionNames.AppName];
const safeProjectNameFromVS = inputs[QuestionNames.SafeProjectName];
const isNet8 = inputs.targetFramework === "net8.0";
const replaceMap = {
...Generator.getDefaultVariables(
appName,
safeProjectNameFromVS,
inputs.targetFramework,
inputs.placeProjectFileInSolutionDir === "true"
),
IsNet8Framework: isNet8 ? "true" : "",
};

return Promise.resolve(
ok([
{
templateName: this.capabilities2TemplateNames[inputs.capabilities as string],
language: ProgrammingLanguage.CSharp,
replaceMap,
},
])
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ describe("TemplateGenerator", () => {
},
TemplateNames.Tab,
],
[
{
[QuestionNames.Capabilities]: CapabilityOptions.tab().id,
[QuestionNames.ProgrammingLanguage]: ProgrammingLanguage.CSharp,
targetFramework: "net9.0",
},
TemplateNames.SsoTabSSR,
],
]);

setTools(new MockTools());
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();

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

app.Run();

0 comments on commit 5922727

Please sign in to comment.