Showing posts with label Custom Application Page. Show all posts
Showing posts with label Custom Application Page. Show all posts

Friday, 23 May 2014

How to set the custom Access Denied page in Sharepoint 2010?

We need to follow the below steps to apply custom Access Denied page replacing the OOB application page.

Steps:

1) Create a new Application Page and name it based on your choice(for example AccessDenied.aspx)

2) Deploy this Application Page in to a different folder under Layouts, so that it wont conflict with OOB default.aspx page in the layouts folder

3) Once the page is deployed run the below powershell command/code /script to set the custom page as the login page

$WebAppURL= read-host "Enter the web application URL to which wish to set the Custom Access Denied Page"
Set-SPCustomLayoutsPage -Identity "AccessDenied" -RelativePath "/_layouts/Login/AccessDenied.aspx" -WebApplication $WebAppURL


Thursday, 10 April 2014

How to apply custom login page for sharepoint webapplication


In order to accomplish this we need to follow the below steps:

Steps 

  • Create a new Application page and deploy the page in a different location in "_layouts" folder. for ex: "_layouts/login"

  • We need to execute few powershell commands to replace the outofbox login page to the new page that we created. For easy use I have written a powershell script to execute set of commands at once.

  • Create a powershell script and add the below code

1:  Add-PsSnapin Microsoft.SharePoint.PowerShell  
2:  $WebAppURL= read-host "Enter the web application URL to which wish to set the Custom Login Page"  
3:  Set-SPCustomLayoutsPage -Identity "Login" -RelativePath "/_layouts/Login/Default.aspx" -WebApplication $WebAppURL  
4:  Remove-PsSnapin Microsoft.SharePoint.PowerShell  
  • The above script will prompt for application url for which you want to set the custom login page.

  • we need to make the below change in Web.config along with the above script execution

   <authentication mode="Forms">
      <forms loginUrl="/_layouts/login/default.aspx" />
    </authentication>

Note: we need to follow the same process above in order to apply custom Access denied page. 

1:  Set-SPCustomLayoutsPage -Identity "AccessDenied" -RelativePath "/_layouts/Login/AccessDenied.aspx" -WebApplication $WebAppURL