I have a Blazor WASM app that is hosted in an aspnet application. The hosting app contains some API routes, and they all seem to be working correctly.
However, my Blazor app needs to dynamically load some content into an iFrame. The src for the iFrame points to a Controller route in my hosting project.
The problem is, the Controller action doesn't get hit. Instead, the iFrame displays the "Page Not Found" page from my WASM app. If I copy the iFrame src url and paste it into my browser, the controller gets called, and the proper content is returned.
It seems as though the Blazor WASM app is intercepting the routing, but I am not sure how to prevent it. I tried using an absolute url for the iFrame src, but it didn't solve the problem.
<iframe src="@url"></iframe>
@code {
string url = "/dynamicContent/myController/myAction";
}
[Route("dynamicContent/[controller]")]
public class MyControllerController : Controller
{
[HttpGet("MyAction")]
public IActionResult MyAction()
{
return View();
}
}
var app = builder.Build();
app.UseResponseCompression();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseWebAssemblyDebugging();
}
else
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseBlazorFrameworkFiles();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.MapRazorPages();
app.MapControllers();
app.MapFallbackToFile("index.html");
app.Run();