Click here to Skip to main content
15,936,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Experts,

In my web application, i have integrated my web application with WIF and ADFS server for the single sign on purpose.
My application is hosted on WIF server and when i hit to my application it will redirect to ADFS server for the user authentication. And ADFS server will authenticate user using Active Directory.

But when some user from out of the domain access the site than ADFS server will not authenticate user so it will redirect user to : 401 - Unauthorized page.

So instead of 401 : Unauthorized page i want to redirect user to some other page of my application and authenticate user using my database and if authenticated then i want to perform Single Sign On for that user.

So how could it be implemented ?

1 solution

You can handle it using Web.Config configuration.

Add something like this in your web.config:
<customErrors mode="On" defaultRedirect="~/Login">
     <error statusCode="401" redirect="~/Unauthorized" />

This will direct user to 'Unauthorized' page. You can put your logic in this page.

Detail here: MSDN: customErrors Element (ASP.NET Settings Schema)[^]

Other way, look here:
Bypass ASP.NET unauthorized redirect to a login page[^]
Share this answer
HardikSitapara 9-May-12 4:37am    
Hi, We can redirect base on your solution. But only redirection is not matter. we have to provide single sign on also so we need to create token for that

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900