I'm very keen to be able to debug a WASM app through Visual Studio AND to test it through IIS, on different devices. Ideally this solution won't involve me having to swap settings or files manually. I have managed to achieve exactly this with a Blazor Server app but am struggling to do the same in WASM.
I have made a brand new Blazor Web Assembly .Net6 app through Visual Studio. It gives me the standard program.cs of:
using BlazorHelp;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
await builder.Build().RunAsync();`
I mention this because many solutions I've seen involve using, presumbly, a WebApplication.CreateBuiulder "builder" object rather than the WebAssemblyHostBuilder object. Possibly confusion with Blazor Server fixes.
At this point I can press play in the IDE and see the app running.
In the IDE I publish the app to a folder and left the default location as is. I copy this location (in the project's \bin\Release\net6.0\browser-wasm\publish folder) to the clipboard.
In IIS I make a new application, added the alias BlazorHelp, chosen my app pool and pasted the path above into the physical path. Before I can test the app through IIS I have to change the app's wwwroot/index.html with:
<base href="/BlazorHelp/" />
Once that's done I can see the app running through IIS but I am now unable to use Visual Studio to debug. When I swap back to:
<base href="/" />
it starts working again in the IDE but not through IIS.
Any clues as to what I'm missing would be most welcome.