1

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();

1 Answer 1

0

It was a caching issue.

I added ?cacheBust={ DateTime.UtcNow.ToFileTime()} to the end of my url and now it's working.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.