.net core 如何修复:“;RangeError:超过最大调用堆栈大小;在angular7中,将令牌作为参数传递时

.net core 如何修复:“;RangeError:超过最大调用堆栈大小;在angular7中,将令牌作为参数传递时,.net-core,angular7,password-recovery,.net Core,Angular7,Password Recovery,我正在尝试完成“密码恢复”功能。密码重置URL包含电子邮件参数和令牌(使用GeneratePasswordResetTokenAsync(TUser)dotnet核心标识函数生成)。 现在的问题是,每当在浏览器上加载重置URL时,它都会给出:RangeError:超出最大调用堆栈大小 为了发现问题,我从url中删除了令牌,并在代码中硬编码了一个变量来观察结果,但它工作得非常好,没有任何例外 此外,组件中没有可能导致问题的循环依赖关系。我不明白是什么导致了这个问题。 PS:我在前端使用Angul

我正在尝试完成“密码恢复”功能。密码重置URL包含电子邮件参数和令牌(使用GeneratePasswordResetTokenAsync(TUser)dotnet核心标识函数生成)。 现在的问题是,每当在浏览器上加载重置URL时,它都会给出:RangeError:超出最大调用堆栈大小

为了发现问题,我从url中删除了令牌,并在代码中硬编码了一个变量来观察结果,但它工作得非常好,没有任何例外

此外,组件中没有可能导致问题的循环依赖关系。我不明白是什么导致了这个问题。 PS:我在前端使用Angular 7,在后端使用C#

编辑:在进一步调查中,我发现当令牌字符串{当我用“System.Web.HttpUtility”编码URL时}或当我不执行编码时}之间包含(%2)时,就会发生异常

URL有什么限制吗?来自app.component.ts的代码片段

setTimeout(() => {
  if (this.isUserLoggedIn) {
    this.alertService.resetStickyMessage();
    this.checkAvailableStocks();
    if (this.isUserLoggedIn && this.UserRole == 'Worker/Staff' && !this.storageManager.getData(DBkeys.SELECTED_COMPANY)) {
      let dialogRef = this.dialog.open(CompanyDialogeComponent, {

        //width: '800px',
        data: {},
        disableClose: true
      });

      dialogRef.afterClosed().subscribe(result => {

      });
    }
    //if (!this.authService.isSessionExpired)
    this.alertService.showMessage("Login", `Welcome back ${this.userName}!`, MessageSeverity.default);
    //else
    //    this.alertService.showStickyMessage("Session Expired", "Your Session has expired. Please log in again", MessageSeverity.warn);
  }
}, 2000);


this.alertService.getDialogEvent().subscribe(alert => this.showDialog(alert));
this.alertService.getMessageEvent().subscribe(message => this.showToast(message, false));
this.alertService.getStickyMessageEvent().subscribe(message => this.showToast(message, true));
this.authService.reLoginDelegate = () => this.shouldShowLoginModal = true;
this.authService.getLoginStatusEvent().subscribe(isLoggedIn => {
  this.isUserLoggedIn = isLoggedIn;


  if (this.isUserLoggedIn) {
    this.initNotificationsLoading();
  }
  else {
    this.unsubscribeNotifications();
  }

  setTimeout(() => {
    if (!this.isUserLoggedIn) {
      this.alertService.showMessage("Session Ended!", "", MessageSeverity.default);
    }
  }, 500);
});

this.router.events.subscribe(event => {
  if (event instanceof NavigationStart) {
    let url = (<NavigationStart>event).url;

    if (url !== url.toLowerCase()) {
      this.router.navigateByUrl((<NavigationStart>event).url.toLowerCase());
    }
  }
});
setTimeout(()=>{
if(this.isUserLoggedIn){
this.alertService.resetStickyMessage();
这是。checkAvailableStocks();
if(this.isUserLoggedIn&&this.UserRole=='Worker/Staff'&&!this.storageManager.getData(DBkeys.SELECTED_COMPANY)){
让dialogRef=this.dialog.open(CompanyDialogeComponent{
//宽度:“800px”,
数据:{},
disableClose:正确
});
dialogRef.afterClosed().subscribe(结果=>{
});
}
//如果(!this.authService.isSessionExpired)
this.alertService.showMessage(“登录”,“欢迎回来${this.userName}!”`,MessageSeverity.default);
//否则
//this.alertService.showStickyMessage(“会话已过期”,“您的会话已过期。请重新登录”,MessageSeverity.warn);
}
}, 2000);
this.alertService.getDialogEvent().subscribe(alert=>this.showDialog(alert));
this.alertService.getMessageEvent().subscribe(message=>this.showtoos(message,false));
this.alertService.getStickyMessageEvent().subscribe(message=>this.showtoos(message,true));
this.authService.reLoginDelegate=()=>this.shouldShowLoginModel=true;
this.authService.getLoginStatusEvent().subscribe(isLoggedIn=>{
this.isUserLoggedIn=isLoggedIn;
if(this.isUserLoggedIn){
this.initNotificationsLoading();
}
否则{
此。取消订阅通知();
}
设置超时(()=>{
如果(!this.isUserLoggedIn){
this.alertService.showMessage(“会话结束!”,“”和MessageSeverity.default);
}
}, 500);
});
this.router.events.subscribe(事件=>{
if(导航启动的事件实例){
让url=(事件).url;
if(url!==url.toLowerCase()){
this.router.navigateByUrl((event.url.toLowerCase());
}
}
});

我在使用dotnet core开发Angular时也遇到过类似的问题

您应该从应用程序组件中删除此代码,因为这段代码正在将dotnet core生成的密码重置令牌转换为小写,并在小写后重定向

this.router.events.subscribe(event => {
 if (event instanceof NavigationStart) {
let url = (<NavigationStart>event).url;

if (url !== url.toLowerCase()) {
  this.router.navigateByUrl((<NavigationStart>event).url.toLowerCase());
}
  }
});
this.router.events.subscribe(事件=>{
if(导航启动的事件实例){
让url=(事件).url;
if(url!==url.toLowerCase()){
this.router.navigateByUrl((event.url.toLowerCase());
}
}
});

我在使用dotnet core开发Angular时也遇到过类似的问题

您应该从应用程序组件中删除此代码,因为这段代码正在将dotnet core生成的密码重置令牌转换为小写,并在小写后重定向

this.router.events.subscribe(event => {
 if (event instanceof NavigationStart) {
let url = (<NavigationStart>event).url;

if (url !== url.toLowerCase()) {
  this.router.navigateByUrl((<NavigationStart>event).url.toLowerCase());
}
  }
});
this.router.events.subscribe(事件=>{
if(导航启动的事件实例){
让url=(事件).url;
if(url!==url.toLowerCase()){
this.router.navigateByUrl((event.url.toLowerCase());
}
}
});

为什么要用小写字母创建url?在app.component中为什么要用小写形式创建url?应用程序内组件右。。我没有意识到这一点。删除这段代码消除了这些异常。谢谢正确的。。我没有意识到这一点。删除这段代码消除了这些异常。谢谢