Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
.NET
.NET Core
.NET MAUI
.NET Standard
Active Directory
ADO.NET
Agile Development
AI
AJAX
AlbertAGPT
Alchemy
Alexa Skills
Algorand
Algorithms in C#
Android
Angular
ArcObject
ASP.NET
ASP.NET Core
Augmented Reality
Avalanche
AWS
Azure
Backbonejs
Big Data
BizTalk Server
Blazor
Blockchain
Bootstrap
Bot Framework
Business
Business Intelligence(BI)
C#
C# Corner
C# Strings
C, C++, MFC
Career Advice
Careers and Jobs
Chapters
ChatGPT
Cloud
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Copilot
Cortana Development
Cosmos DB
Cryptocurrency
Cryptography
Crystal Reports
CSS
Current Affairs
Custom Controls
Cyber Security
Data Mining
Data Science
Databases & DBA
Databricks
Design Patterns & Practices
DevExpress
DevOps
DirectX
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
F#
Files, Directory, IO
Flutter
Games Programming
GDI+
General
Generative AI
GO
Google Cloud
Google Development
Graphics Design
Graphite Studio
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Infragistics
Internet & Web
Internet of Things
Ionic
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
Kotlin
Langchain
Leadership
Learn .NET
Learn iOS Programming
LINQ
Machine Learning
Metaverse
Microsoft 365
Microsoft Fabric
Microsoft Office
Microsoft Phone
Microsoft Teams
Mobile Development
MongoDB
MuleSoft
MySQL
NEAR
NetBeans
Networking
NFT
NoCode LowCode
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Polygon
PostgreSQL
Power Apps
Power Automate
Power BI
Power Pages
Printing in C#
Products
Progress
Progressive Web Apps
Project Management
Public Speaking
Python
Q#
QlikView
Quantum Computing
R
React
React Native
Reports using C#
Robotics & Hardware
RPA
Ruby on Rails
RUST
Salesforce
Security
Servers
ServiceNow
SharePoint
Sharp Economy
SignalR
Smart Devices
Snowflake
Software Architecture/Engineering
Software Testing
Solana
Solidity
Sports
SQL
SQL Server
Startups
Stratis Blockchain
Swift
SyncFusion
Threading
Tools
TypeScript
Unity
UWP
Visual Basic .NET
Visual Studio
Vue.js
WCF
Wearables
Web API
Web Design
Web Development
Web3
Windows
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML
XML
XNA
XSharp
Register
Login
0
Answer
Mix angularjs http error handling and MVC custom page error?
Dawood Abbas
4y
1.2k
1
Reply
How to Mix angularjs http error handling and MVC custom page error?
I need to manage page not found and server propblem erros by redirect to my own custom error pages, so I done this by following, and its working fine.
web.config
"On"
>
"400"
redirect=
"~/Error/Error400"
/>
"404"
redirect=
"~/Errors/Error404"
/>
"403"
redirect=
"~/Error/Error403"
/>
"500"
redirect=
"~/Errors/Error500"
/>
so now when I need to get the angularjs http erros like 404 by follwing code in which passing wrong methode (GetDetai) which is not available in controller (actual is 'GetDetails').
$http({
method:
'GET'
,
url:
'/Admin/Dashboard/GetDetai'
,
headers: {
"Content-Type"
:
"application/json"
}
}).then(
function
(result) {
console.log(result);
$scope.GetCustomer = result.data;
},
function
(reason) {
console.log(reason);
if
(reason.status ==
'404'
) {
console.log(
'Invalid Methode/Url.'
);
}
else
if
(reason.status ==
'505'
) {
console.log(
'Internal server error.'
);
}
});
then its not ctaching the 400 error in error function, its going into then function and displaying below
First Console log
{data: "
↵
↵
↵>
↵
<
html
>
↵
<
head
>
↵
<
meta
c…white;"
>
Go Back To Home
a
>
↵
body
>
↵
html
>
↵
↵", status: 200, config: {…}, statusText: "OK", headers: ƒ, …}
data: "
↵
↵
↵>
↵
<
html
>
↵
<
head
>
↵
<
meta
charset
=
"utf-8"
/>
↵
<
title
>
title
>
↵
<
style
>
↵ body {
↵ display: inline-block;
↵ background: #00AFF9 url(https://cbwconline.com/IMG/Codepen/Unplugged.png) center/cover no-repeat;
↵ height: 100vh;
↵ margin: 0;
↵ color: white;
↵ }
↵
↵ h1 {
↵ margin: .8em 3rem;
↵ font: 4em Roboto;
↵ }
↵
↵ p {
↵ display: inline-block;
↵ margin: .2em 3rem;
↵ font: 2em Roboto;
↵ }
↵
style
>
↵
head
>
↵
<
body
>
↵
<
h1
>
Whoops!
h1
>
↵
<
p
>
Something went wrong
p
>
<
br
/>
<
br
/>
↵
↵
<
a
href
=
"/Home/Index"
style
=
"color:white;"
>
Go Back To Home
a
>
↵
body
>
↵
html
>
↵
↵"
status: 200
headers: ƒ (name)
config: {method: "GET", transformRequest: Array(1), transformResponse: Array(1), jsonpCallbackParam: "callback", paramSerializer: ƒ, …}
statusText: "OK"
xhrStatus: "complete"
__proto__: Object
But when I commented/removed that web.config custom error code then this angularjs http call error function working properly, getting expected 404 error.
So How to manag these both kind of errors properly with non dipendencies and non effect on other codes?
Post
Reset
Cancel
Answers (
0
)
Next Recommended Forum
Search Domain Name if exist in google
Dropdownlist not hold selected value while use pagination