I'm developing a 'error 404' page using C# and asp.net. The problem is, when the user types [www.example.com/asdasd](http://www.example.com/asdasd) he is redirected to my error 404 page, but I wanted the url to stay the same.

For example, the user types 'www.example.com/asdasd', I wanted to stay 'www.example.com/asdasd' not 'www.example.com/error' (which is the name of my error 404 page that I'm wrongly redirecting).

This is my 'Custom Errors' inside my web.config file

```
<customErrors mode="On" defaultRedirect="~/error/" redirectMode="ResponseRedirect">
    <error statusCode="404" redirect="~/error/" />
</customErrors>

```

This is my function inside Global.asax

```
 protected void Application_Error(object sender, EventArgs e)
        {
            Exception ex = Server.GetLastError();
            if (ex is HttpException && ((HttpException)ex).GetHttpCode() == 404)
            {
                Response.Redirect("~/error");
            }
        }

```

Any ideas or suggestions ?