I'm making a project where my login form goes to another function in the controller with a different name. I want to send error message in the current view from that function. How can I do it? Thank you
-
you can call controller function using AJAX and then show on the client-side response, another way is to return the same view with some data in Model and update your Razor code to show this error but first approach is better.Dmytro Shabanov– Dmytro Shabanov2019-12-23 15:40:49 +00:00Commented Dec 23, 2019 at 15:40
Add a comment
|
1 Answer
You can use TempData["Keyword"] for this. If the controller follows another httpRequest then also it holds the data until it is read.
Controller
TempData["Error"]="This is error";
View from Other Controller
<lable>@TempData["Error"]</lable>
Fro better understanding
Click HERE
1 Comment
Rajan Mishra
Happy to help danyal and please vote up when u can.