Search code examples
c#asp.netvb.netsharepointsharepoint-2007

Unpublished page in sharepoint prompts for user authentications


I create a page in sharepoint 2007. This page has no published version yet. So expectedly, when I access this page using anonymous access, it will redirect to 404 page but unfortunately sharepoint has different behavior, instead it ask for user authentication.

Why does sharepoint prompts for user authentication? Is this the expected behavior of sharepoint? If so, is there away that I can redirect it to 404 page and never ask for user authentication?


Solution

  • First, I created a httpmodule that will intercepts any aspx requests. In this httpmodule, I retrieve the file version of the requested page and check if the current version is equal to 0 (because the page has no current published version). If the current version is equal to zero then redirect it to 404page.aspx.

    Second, when registering the httpmodule, ensure that it is the first element under the httpmodule in the web.config file. This is to ensure that our module will be the first to be called. This is important to ensure that the authentication will not be executed.