I need to return an alert message from a action in a controller in asp.net mvc, is it possible ? I tried getting the page instance and calling the RegisterJavaScript funtion but the page instance is null always because I read that its the MVC handler now not the page handler. I know I can return a javscript result but my action is doing a redirect to a different url just before redirecting I need to show the message. Could somebody help me ? I cannot use a viewbag or viewdata because its on a post that I need to show the message and its not going back to the view once post is done. So there is no way to check for the variable value and show the message.
public ActionResult RedirectToURL(ObjectData obj)
{
if (ModelState.IsValid())
{
process code here
}
else
{
ModelState.AddModelError("Error", "Fill in the required fields");
return View("TestView", ObjectData);
}
//Post data to the URL.
//Prepare Data to Post
//Need JavaScript call here....
return this.RedirectAndPost(Url, dataToPost);
}