danyal ahmad
danyal ahmad

Reputation: 25

Sending a message to a view from a different method in controller in MVC

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

Upvotes: 1

Views: 571

Answers (1)

Rajan Mishra
Rajan Mishra

Reputation: 1178

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

Upvotes: 1

Related Questions