aspnet / BasicMiddleware

[Archived] Basic middleware components for ASP.NET Core. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
169 stars 84 forks source link

How to ? - Rewrite and default doc #225

Closed alvipeo closed 5 years ago

alvipeo commented 7 years ago

For Angular 4 app in my ASP.NET Core MVC app I need to set up Core MVC Rewrite so:

Is this possible at all? Sorry, this place is the only hope...

Here's what I have now:

    app.UseDefaultFiles();
    app.UseStaticFiles();

    app.UseRewriter(new RewriteOptions().AddRewrite("/app(/.*)?$", "index.html", true));

    app.UseIdentity();

    app.UseMvc(routes =>
    {
        routes.MapRoute(
            name: "default",
            template: "{controller=Home}/{action=Index}/{id?}");
    });

I tried different settings, no luck. I get 404 on anything starting with localhost/app.

muratg commented 6 years ago

@alvipeo does swapping the order of UseStaticFiles and UseRewriter calls help this? The idea is you want the [anything] section to be rewritten before it's declared a static file.

Let me know if that helps with your problem!

alvipeo commented 6 years ago

@muratg I'm going to try this tomorrow! I kinda left the idea but came back to it today with another project. Need to have it fixed.

muratg commented 5 years ago

Hi. We're closing this issue as no response or updates have been provided in a timely manner and we have been unable to reproduce it. If you have more details and are encountering this issue please add a new reply and re-open the issue.