1

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

1
  • 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. Commented Dec 23, 2019 at 15:40

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

Happy to help danyal and please vote up when u can.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.