Skip to content

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

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

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

wants to merge 1 commit into from

Conversation

mzhukovs
Copy link

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
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";
            });
        }
    }
}

@posva posva added the need review Needs to be reviewed by someone who know about the topic label Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs need review Needs to be reviewed by someone who know about the topic
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants