SPA with Angular
I want use abp vnext with Angular,add officical identity、permissionManager、audit modules,but i don't know how to work, could you give a sample step by step like Acme.BookStore MVC Sample
Will create a SPA startup template. However, I can not give a step by step sample, that is not trival.
hi,@hikalkan do you have plan to create a spa startup template for angular ? (just a sample ,no step by step document required) ?
@ChangYinShung we have already created Angular startup template (see https://docs.abp.io/en/abp/latest/Getting-Started?UI=NG&DB=EF&Tiered=No). Do you mean something else?
@hikalkan when i follow this tutorial(https://docs.abp.io/en/abp/latest/Getting-Started?UI=NG&DB=EF&Tiered=No): When deploy it to IIS, i need to create two port on iis(one for angular,other for backend) .
In some case, i need deploy angular and backend in same port(80).
1.I install nuget Microsoft.AspNetCore.SpaServices.Extensions on .HttpApi.Host and add UseSpa
app.UseAuditing();
app.UseConfiguredEndpoints();
app.UseSpaStaticFiles();
app.UseSpa(spa =>
{
// To learn more about options for serving an Angular SPA from ASP.NET Core,
// see https://go.microsoft.com/fwlink/?linkid=864501
spa.Options.SourcePath = "wwwroot/dist";
});
2.Run build angular and move angular dist folder to wwwroot folder
3.create an site and deploy to iis.
What is best practice for deploy an SPA application(angular) ?
For the ABP Commercial demo, we are using the same port for Angular & Backend. But I am not sure if we've used the Microsoft.AspNetCore.SpaServices.Extensions. @ismcagdas?
We had created a "One solution (include the client side project into the server side solution instead of separate solutions)" for the ASP.NET Boilerplate download before. We may consider to add a similar thing here. Is that what do you want? If so, can you create a new issue please?
We don't use Microsoft.AspNetCore.SpaServices.Extensions. In order to host both apps on the same port, we include a custom middleware for ASP.NET Core project which redirects all not found URLs to Angular project's index.html. Something like this;
app.Use(async (ctx, next) =>
{
if (ShouldRedirectToAngularApp(ctx))
{
ctx.Request.Path = "/index.html";
await next();
}
else
{
await next();
if (ShouldRedirectToAngularApp(ctx))
{
ctx.Request.Path = "/index.html";
await next();
}
}
});
private static bool ShouldRedirectToAngularApp(HttpContext ctx)
{
return ctx.Response.StatusCode == 404
&& !Path.HasExtension(ctx.Request.Path.Value)
&& !ctx.Request.Path.Value.StartsWith("/api/services", StringComparison.InvariantCultureIgnoreCase);
}
We had created a "One solution (include the client side project into the server side solution instead of separate solutions)" for the ASP.NET Boilerplate download before. We may consider to add a similar thing here. Is that what do you want? If so, can you create a new issue please?
yes, i will create new issue thanks.