SkillAgentSearch skills...

RouterHistory

用于Vue单页面应用,使用VueRouter的History模式下,通过AspNetCore提供文件服务。

Install / Use

/learn @SpringHgui/RouterHistory
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

RouterHistory

Nuget

用于单页面应用,使用History模式下,通过AspNetCore提供文件服务。

使用

  1. 使用nuget安装RouterHistory
  2. app.UseRouting,app.MapControllersapp.UseStaticFiles() 之后添加app.UseRouterHistory();,以提供性能。
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }
    else
    {
        app.UseExceptionHandler("/Home/Error");
        // 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.UseRouting();
    
    // 添加这一行即可
    app.UseRouterHistory();

    app.UseAuthorization();

    app.UseEndpoints(endpoints =>
    {
        endpoints.MapControllerRoute(
            name: "default",
            pattern: "{controller=Home}/{action=Index}/{id?}");
    });
}
  1. 将编译后的文件放到wwwroot目录内
  2. 开始体验吧。

遇到问题

请提交issue给作者

View on GitHub
GitHub Stars14
CategoryDevelopment
Updated2mo ago
Forks2

Languages

C#

Security Score

80/100

Audited on Jan 22, 2026

No findings