My 404 redirection to the NotFound (Controller Action) is not working while deployed in Azure Websites. I am getting normal browser 404 instead of my custom 404 page. But they work locally when debugging in localhost in Visual Studio. This is my Web.Config
.
<system.web>
<!-- ........ -->
<customErrors mode="RemoteOnly" defaultRedirect="~/Error/Index">
<error redirect="~/Error/NotFound" statusCode="404" />
</customErrors>
</system.web>
My ErrorController:
public class ErrorController : Controller
{
public ViewResult Index()
{
ViewBag.Title = "Error Page";
var model = new ErrorViewModel() {ErrorMessage = "Sorry for the error!", TitleBar = "Error Page"};
return View("Error", model);
}
public ViewResult NotFound()
{
Response.StatusCode = 404; //you may want to set this to 200
return View("PageNotFound");
}
}
Will appreciate your help.