'How Can I Render CSHTML From A MapGet Route (ASP.NET Core)?

I'm developing an ASP.NET Core project and I'm trying to do dynamic routing, so if I go to /page/[str] it returns something custom depending on [str]. I can return a string like so:

app.MapGet("/page/name:alpha", (string name) => {
    return name;
});

Is there a way to render a cshtml and cshtml.cs file?

I looked at the ASP.NET Core but I couldn't find anything about this.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source