S
S
Sasha Pleshakov2016-07-27 16:04:52
ASP.NET
Sasha Pleshakov, 2016-07-27 16:04:52

Is it possible to show an error page with the old url?

Web.config:

<customErrors mode="On">
   	<error statusCode="404" redirect="/Http404.html" />
</customErrors>

url after the error: "Http404.html?aspxerrorpath=/home/sup/", but I would like it to remain "/home/sup/". Is it possible?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Nemiro, 2016-07-27
@mnepoh

You can use error handling at the web server level:

<system.webServer>
  <httpErrors errorMode="Custom" existingResponse="Replace">
    <remove statusCode="404" />
    <error statusCode="404" path="/Http404.html" responseMode="ExecuteURL" />
  </httpErrors>
</system.webServer>

customErrors is better to remove. You may need to restart IIS or the worker process
after making changes to web.config . For reference: customErrors is the old version of error handling, at the level of a single application / site ( ASP.NET ). httpErrors - works at the IIS level . Part of IIS7 and above. As a result, when a configuration is changed, it may be necessary to restart IIS or the worker process for the web server to load the new configuration. When working with IIS Express in Visual Studio , the change in web.config
web server settings - this is a small pitfall that you should not forget about and always restart IIS Express .
customErrors can also be configured, but only for ASP.NET pages (or using a server-side handler):
<system.web>
  <customErrors mode="On" redirectMode="ResponseRewrite"> 
    <error statusCode="404" redirect="/Error404.aspx" />
  </customErrors>
</system.web>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question