1

I currently have the following in my web.config:

<customErrors mode="On" defaultRedirect="~/Error">
  <error statusCode="404" redirect="~/Error/NotFound"/>
</customErrors>

I have an Error Controller with:

public class ErrorController : Controller
{
    // GET: Error
    public ActionResult Index()
    {
        return View();
    }

    public ActionResult NotFound()
    {
        return View();
    }
}

404 seems to work, but for any other error the application keeps going to:

localhost/Error

It drops the application name from the url. I tried adding it into the defaultRedirect = "~/MyApp/Error" also tried to make it "~/Error1" instead of "Error" just to check, but in both cases any error would go to localhost/Error.

Do I need to do something extra?

ataravati
  • 8,891
  • 9
  • 57
  • 89
Paritosh
  • 4,243
  • 7
  • 47
  • 80
  • Take a look at this [SO](http://stackoverflow.com/questions/619895/how-can-i-properly-handle-404-in-asp-net-mvc) – Siva Gopal Oct 26 '15 at 18:26
  • Ugh..my fault I see why I was always going to localhost/Error, there was an ajax call which was redirecting to Error, I adjusted it and now it's fine. – Paritosh Oct 26 '15 at 19:10

0 Answers0