Closed SemeniakoTaras closed 4 years ago
If I create new Azure Functions project, this works for me.
You are not supposed to install Microsoft.AspNetCore.Razor.Language
by your own
namespace FunctionApp1
{
public static class Function1
{
[FunctionName("Function1")]
public static async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string name = req.Query["name"];
RazorEngine razorEngine = new RazorEngine();
RazorEngineCompiledTemplate template = razorEngine.Compile("hello @Model.Name");
template.SaveToFile("template.bin");
RazorEngineCompiledTemplate template2 = RazorEngineCompiledTemplate.LoadFromFile("template.bin");
string result = template2.Run(new { Name = name });
return name != null
? (ActionResult)new OkObjectResult(result)
: new BadRequestObjectResult("Please pass a name on the query string or in the request body");
}
}
}
Hi there. Trying to use your lib in my project with Azure Function. I am getting the next issue that I mentioned above.
In the output window, it says "Exception thrown: 'System.IO.FileNotFoundException' in RazorEngineCore.dll", but actually my template exists...
I tried to install such Microsoft.AspNetCore.Razor.Language Version=3.1.1 in the project directly, but it still says the same.
Any thoughts?