Open Closed

redirect to login page without exception show if user not logined #5096


User avatar
0
hamidsharifi created

Hi When a user is not login the app show the error box and after click on close error box redirect to login page. i want to redirect to login page without show error box. the error box is like below

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

1 Answer(s)
  • User Avatar
    0
    masum.ulu created
    Angular Expert

    Hello Hamid,

    Which type UI you using ? If it's angular you can customize specific error code check the documentation

    Example

    custom-error.handler.ts

    //app/shared/handlers/custom-error.handler.ts
    import { Injector } from '@angular/core';
    import { HttpErrorResponse } from '@angular/common/http';
    import { throwError } from 'rxjs';
    import { AuthService } from '@abp/ng.core';
    
    export function handleHttpErrors(injector: Injector, httpError: HttpErrorResponse) {
      if (httpError.status === 401) {
        injector.get(AuthService).navigateToLogin();
        return;
      }
    
      return throwError(() => httpError);
    }
    

    app.module.ts

    //app/app.module
    import {HTTP_ERROR_HANDLER} from '@abp/ng.theme.shared';
    import {handleHttpErrors} from './shared/handlers/custom-error.handler';
    //Other imports..
    
    @NgModule({
      imports: [
       //Modules
      ],
      providers: [
        APP_ROUTE_PROVIDER,
        //ADD THE BELOW CODE
        { provide: HTTP_ERROR_HANDLER, useValue: handleHttpErrors }
      ],
      declarations: [],
      bootstrap: [],
    })
    export class AppModule {}
    
    
    

    Result

    As you can see I'm directly redirecting to login

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.