如何解决如何防止我的网址被重置?
我需要你帮助路由一个 asp.net core 5 / angular 10 应用程序。
实际上,当我在我所在的任何部分刷新我的应用程序 (f5) 时,它总是将我指向初始路径。
例如,如果它们在路径 http://localhost:44325/rooms
或 http://localhost:44325/rooms-types/5
中,重新加载页面总是返回基本路径 http://localhost:44325
。
我该如何改变这种行为?当我重新加载页面时,我希望自己处于刷新前所在的同一部分。 我附上了包含路由的文件和 startup.cs 文件
谢谢大家
我的 app-routing.module.ts
const routes: Routes = [
// Tipologie Camere
{
path: 'rooms',component: RoomsDataGridComponent
},{
path: 'rooms-types/edit/:id',component: RoomsTypesFormComponent
},];
@NgModule({
imports: [RouterModule.forRoot(routes)],exports: [RouterModule]
})
export class AppRoutingModule { }
我的startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "ClientApp/dist";
});
services.AddDbContext<DBContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddDatabaseDeveloperPageExceptionFilter();
}
public void Configure(IApplicationBuilder app,IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
if (!env.IsDevelopment())
{
app.UseSpaStaticFiles();
}
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";
if (env.IsDevelopment())
{
spa.UseAngularCliServer(npmScript: "start");
}
});
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。