We have an external agency auditing our site at the moment and one of the recommendations they have is to return a 404 response code for the actual custom 404 page itself.
Our custom 404 works fine in every other respect, so if you generate a 404 page by deliberately going to a non-existent page the correct 404 response is generated.
The custom 404 page /404/ returns 200 I guess because it's a valid page which exists in Umbraco. Is there anyway to force this to also have a 404 response code?
For info, I'm specifying my 404 in the umbracoSettings.config
<errors>
<error404>15969</error404>
<!--
The value for error pages can be:
* A content item's integer ID (example: 1234)
* A content item's GUID ID (example: 26C1D84F-C900-4D53-B167-E25CC489DAC8)
* An XPath statement (example: //errorPages[@nodeName='My cool error']
-->
<!--
<error404>
<errorPage culture="default">1</errorPage>
<errorPage culture="en-US">200</errorPage>
</error404>
-->
</errors>
Custom 404 page returns 200 status
Hi,
We have an external agency auditing our site at the moment and one of the recommendations they have is to return a 404 response code for the actual custom 404 page itself.
Our custom 404 works fine in every other respect, so if you generate a 404 page by deliberately going to a non-existent page the correct 404 response is generated.
The custom 404 page /404/ returns 200 I guess because it's a valid page which exists in Umbraco. Is there anyway to force this to also have a 404 response code?
For info, I'm specifying my 404 in the umbracoSettings.config
In the web.config I have
Thanks Stuart
Hi Stuart,
Yes, you can change the response code. You can set it in the view by doing something like
Response.StatusCode = 404
I think.I don't have sample code to hand but it can be done that way. It might be more like
Request.Response.SetStatusCode
or something similarNik
wow...that was simpler than I thought haha
Thanks a lot Nik, works perfectly...I was thinking that i'd missed something in an Umbraco config file somewhere or web.config setting.
is working on a reply...