C# 在客户端ASP.NET MVC中显示错误消息
我试图在用户输入错误密码时显示消息。 在服务器中显示更正消息,但在客户端浏览器中显示错误请求消息。 这是控制器中的代码C# 在客户端ASP.NET MVC中显示错误消息,c#,asp.net-mvc,iis,vue.js,axios,C#,Asp.net Mvc,Iis,Vue.js,Axios,我试图在用户输入错误密码时显示消息。 在服务器中显示更正消息,但在客户端浏览器中显示错误请求消息。 这是控制器中的代码 throw new Exception ("Incorrect"); Vue模板 axios.post(window.url + 'usuarios/LogIn', this.data).then((response) => { console.log('Correct') }).c
throw new Exception ("Incorrect");
Vue模板
axios.post(window.url + 'usuarios/LogIn', this.data).then((response) => {
console.log('Correct')
}).catch((error) => {
// Error
if (error.response) {
console.log(error.response.data);
this.error = error.response.data;
} else if (error.request) {
console.log(error.request);
this.error = error.request;
} else {
console.log('Error', error.message);
this.error = error.mes;
}
服务器异常不会传递给响应。您需要构建一个响应手册。您能解释一下如何做到这一点吗?假设您使用的是web API,那么
返回BadRequest(“不正确”)