New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add .net mvc example server config for history mode #2553

Open
wants to merge 1 commit into
base: dev
from

Conversation

Projects
None yet
3 participants
@mzhukovs
Copy link

mzhukovs commented Dec 25, 2018

This should be helpful for some folks from the .NET world to get routing properly setup in their [Core] MVC app. Currently, there is no sample under the server config section on this page in the docs.

@posva posva added the docs label Dec 25, 2018

@lloydjatkinson

This comment has been minimized.

Copy link

lloydjatkinson commented Dec 27, 2018

I think it would be important to differentiate in the docs between the configuration for a normal multi-page app and a SPA with REST API backend.

For example this is my configuration for an ASP.NET Core MVC REST API with a Vue SPA.

    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            // In production, the Vue files will be served from this directory
            services.AddSpaStaticFiles(configuration =>
            {
                configuration.RootPath = "ClientApp/client-app/dist";
            });
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseSpaStaticFiles();
            app.UseMvc();

            app.UseSpa(spa =>
            {
                spa.Options.SourcePath = "ClientApp/client-app";
            });
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment