1

If a user who don't have access to site, visits the site then he should see my custom page instead of Access Denied or Access Request page. Is this possible?

1

Yes it is! There is a very cool TechNet article on how to create a custom access denied page, however you need to have access a Front End server with a farm administrator account.

Apart from the Farm Adm account that also has the SharePoint_Shell_Access role for the farm configuration database, I think you would need some HTML/ASP knowledge.

Alternatively, you could create a HTTP Handler to intercept each request and redirect to your custom page. Check this blog post. And this is an code example of a Handler class.

public class CustomAccessDenied : ISPCustomRedirectHandler
{
    public string GetRedirectUrl(string key)
    {
        string serverRelativeUrl = string.Empty;

        var ctx = HttpContext.Current.Items["DefaultSPContext"];
        if (ctx != null)
        {
            serverRelativeUrl = ((SPContext)ctx).Web.ServerRelativeUrl;

            if (serverRelativeUrl.Equals("/"))
            {
                serverRelativeUrl = string.Empty;
            }
        }

        return string.Format("{0}/_layouts/15/myCode/CustomAccessDenied.aspx", serverRelativeUrl);
    }
}

To learn more about the redirect module, Microsoft(link in the comments) has a nice Walkthrough on how to create and register a custom module.

  • Walkthrough Microsoft TechNet – Murilo Santana Jun 9 '16 at 4:22
  • Were you able to implement the custom pages? – Murilo Santana Jun 22 '16 at 0:27
  • Didn't try this one, as I don't have farm administrator account. But thanks for your answer @Murilo Santana – Ankit Jetani Oct 5 '16 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.