none
How to redirect to home Page if User Cancel Login

    Question

  • i have created a sharepoint 2013 site.

    Enable anonymous access to site. Also i have provided Sign In link on page.

    If anonymous user press sign in or any system user wants to sign in and suddenly he press Cancel button

    it shows

    401 UNAUTHORIZED.

    How could i redirect in such a case to home page.

    Wednesday, October 30, 2013 5:33 AM

Answers

  • Niraj,

    If you are handling custom login through your code then put it in try catch and give update wsp to your user

    If you are using NTLM or inbuilt login (NTLM/SQL) then use custom error and re-direct through IIS for 401. But in this method any page under your web application with 401 will get redirected not only login page, so check feasibility first.


    Thursday, October 31, 2013 12:33 PM

All replies

  • Include home page URL in query string parameters and name it as Source.

    Example:

    Http://Server/sites/Signin.aspx?Source=http://Server/home.aspx


    Bala

    Wednesday, October 30, 2013 6:01 AM
  • Hi Bala,

    Please elaborate in detail,

    how to add to query string and next....

    Wednesday, October 30, 2013 6:20 AM
  • 1. Configure custom error page from your IIS, and into it give url of your login page for 401 error code.

    <SafeModeMaxControls="200"CallStack="true"DirectFileDependencies="10"TotalFileDependencies="50"AllowPageLevelTrace="false">

    <customErrors mode="On"defaultRedirect="/login.aspx">

    Or.

    2. If you can catch exception on your page(Custom code for events then) "

      properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl;
        properties.RedirectUrl = "http://yoursite/login.aspx"

    Or

    Catch http request handler for farm and check catch for that app's login failed code then simply server.redirect may do also.

    I have put all custom code for my application into try catch and catch block with standard logging error in custom list and re-directing to my custom error page.

    Wednesday, October 30, 2013 6:54 AM
  • When you are taking user to Sigin page, pass the root URL in query string parameter as I mentioned above.

    This will automatically handles the page response on submit or cancel.


    Bala

    Wednesday, October 30, 2013 9:51 AM
  • What if i give a .wsp to user, still i have to do chabges @ client side in IIS?
    Wednesday, October 30, 2013 10:06 AM
  • Niraj,

    If you are handling custom login through your code then put it in try catch and give update wsp to your user

    If you are using NTLM or inbuilt login (NTLM/SQL) then use custom error and re-direct through IIS for 401. But in this method any page under your web application with 401 will get redirected not only login page, so check feasibility first.


    Thursday, October 31, 2013 12:33 PM