Redirect unauthenticated users to my own login page
Hello,
I have demo folder in my sitefinity app. Demo folder contains pdf files. I want to do something like when someone search pdf and click on it, user must be redirect to my custom login page instead ofsitefinity login page. I did the below code in web.config file and it works fine but i am redirecting tositefinity login page. I want to redirect users to my custom login page. Can any one suggest me the code or something help !! Here is the web.config code:
<location path="doc">
<system.web>
<authorization>
<allow users="Admin"/>
<deny users="*"/>
<!--Deny everyone else Admin role Users-->
</authorization>
</system.web>
</location>
Hi,
Thank you for using our services!
You can set permissions to the .pdf that shouldn't be visible for Anonymous users. Please take a look at this blog post,where we show how an Unauthorized event can be used in the Global.asax file.
http://www.sitefinity.com/blogs/stefani-tacheva-s-blog/2013/02/01/redirect-unauthorized-users-to-a-custom-page
This event is fired, whenever a user that doesn't have permissions, is redirected to some page. I believe it will suit your scenario.
Let me know if you have any additional questions!
Jen,
Thanks for reply. I am facing this issue from a week. I tried the post you given earlier also but every time it is redirecting me to sitefinity login page. Than i put debug point in global.asax file and saw in global.asax that application_start event is not firing. How should i create custom authorization.!! As i mentioned earlier in my first question i put a piece of code in web.config. Is it the right way ??
Another thing i tried is to create custom handler ihttphandler and it is working but only statik pdf links not for the pdfs that i uploaded from documents & files.!!
I am asking for pdfs becuase i search pdfs with search and search results widget and than if any user clicks on pdf link than he/she must be redirected to my custom login page.
Please provide the solution asap.
Thanks & Regards.