473,545 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

asp.net forms authentication override based on individual pages.

Hi,
I have a asp.net application with forms authentication enabled.
Users create private (database driven) messages (pages; like a message
board) that is only viewed by logged in users.

Now I need to give the users the ability to publish these messages to the
public (if they decide the content is public safe).

Question is... is there a method to override forms authentication?
For an example; some thing like a method... where I look at the URL and
retrun true or false... so forms authentication is ignored based on this
method return value....
Basically to programatically ignore forms authentication for that request
only.

Any direction is deply appreciated
Thanks
Nalaka
Jul 6 '07 #1
5 2337
There are two ways to solve this problem.

1. Have a second page for public access to messages that filters for
messages where IsPublic=true.
2. Write your own authentication bits for the "display message" page that
alters the query based on whether the user is logged in or not.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

*************** *************** *************** ***
Think outside the box!
*************** *************** *************** ***
"Nalaka" <na******@nospa m.nospamwrote in message
news:uv******** ******@TK2MSFTN GP02.phx.gbl...
Hi,
I have a asp.net application with forms authentication enabled.
Users create private (database driven) messages (pages; like a message
board) that is only viewed by logged in users.

Now I need to give the users the ability to publish these messages to the
public (if they decide the content is public safe).

Question is... is there a method to override forms authentication?
For an example; some thing like a method... where I look at the URL and
retrun true or false... so forms authentication is ignored based on this
method return value....
Basically to programatically ignore forms authentication for that request
only.

Any direction is deply appreciated
Thanks
Nalaka


Jul 7 '07 #2
Hi,
The feature I like in "forms authentication" is that, it first sent to login
page, and be auto forwarded to the requested page after login.

And I noticed that this is acoomplished through a URL modification when
calling login page.
like ....
http://www.my.com/login.aspx?ReturnU...ectedPage.aspx

I will try to simulate this URL thing... and to a manual redirect to the
login page with the requested URL.
Hope this calling login page manually will auto redirect after login to the
"original requested URL".

Question is... if this works... are there any issues that I have to worry
about?

Thanks
Nalaka
"Nalaka" <na******@nospa m.nospamwrote in message
news:uv******** ******@TK2MSFTN GP02.phx.gbl...
Hi,
I have a asp.net application with forms authentication enabled.
Users create private (database driven) messages (pages; like a message
board) that is only viewed by logged in users.

Now I need to give the users the ability to publish these messages to the
public (if they decide the content is public safe).

Question is... is there a method to override forms authentication?
For an example; some thing like a method... where I look at the URL and
retrun true or false... so forms authentication is ignored based on this
method return value....
Basically to programatically ignore forms authentication for that request
only.

Any direction is deply appreciated
Thanks
Nalaka


Jul 12 '07 #3
Hi Nalaka,

Do you mean to use FormsAuthentica tion.RedirectFr omLoginPage to redirect to
the page if the user is anonymous but the page is a public one? Please note
this method is used to redirect an authenticated user back to the
originally requested URL. I don't think it's a good idea to redirect for
anonymous user.

Personally I think Gregory's first suggestion is better and simpler to
implement.
Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 13 '07 #4
Hi Walter,
I have a page that should be authenticated under certain request parameters.
So, in the load method of this page, I check to see if the page needs
authentication or annonumous.

In the load method, if authentication is needed, and not a already
authenticated, I redirect the user to the login page.
(In the redirect URL I also pass in parameters like
"ReturnUrl=%2fN otProtectedFold er%2fDefault.as px")

Then after legitimated login using loginPage.... asp.net sends the user back
to the originally requested URL (that was in the parameters).
Seem to work fine... when I tested.
This is not a protected folder... all I want is to go through loginPage...
only if (based on request parameters) the user needs to be
authenticated.. ...

Nalaka


"Walter Wang [MSFT]" <wa****@online. microsoft.comwr ote in message
news:gy******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Nalaka,

Do you mean to use FormsAuthentica tion.RedirectFr omLoginPage to redirect
to
the page if the user is anonymous but the page is a public one? Please
note
this method is used to redirect an authenticated user back to the
originally requested URL. I don't think it's a good idea to redirect for
anonymous user.

Personally I think Gregory's first suggestion is better and simpler to
implement.
Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no
rights.

Jul 16 '07 #5
Hi Nalaka,

Thanks for the detailed explanation. If the folder where the page is
located not protected, then I think this approach should work.

Thank you again for sharing your experience here.
Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 17 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1416
by: abdulrauf | last post by:
Hope someone can help. I am trying to build an application that will allow a user to access/deny an application, the application's individual pages, and the forms within the individual pages. For example once a user log's in the application will check whether the user can access the application's main page. If so it lets him/her see the...
3
4845
by: Kris van der Mast | last post by:
Hi, I've created a little site for my sports club. In the root folder there are pages that are viewable by every anonymous user but at a certain subfolder my administration pages should be protected by forms authentication. When I create forms authentication at root level it works but when I move my code up to the subfolder I get this...
2
2532
by: Jenny | last post by:
Hi all How can the following problem be solved: My application uses forms authentication. Normally a start.aspx page should be send to the client before login.aspx is shown. Start.aspx consist of simple JScript writing a cookie about screen resolution followed by an automatic transfer to login.aspx. This page is therefore test whether...
0
4202
by: Anonieko Ramos | last post by:
ASP.NET Forms Authentication Best Practices Dr. Dobb's Journal February 2004 Protecting user information is critical By Douglas Reilly Douglas is the author of Designing Microsoft ASP.NET Applications and owner of Access Microsystems. Doug can be reached at doug@accessmicrosystems.com....
4
2645
by: MR. UNDERHILL | last post by:
I want to use forms authentication on my website. Looking at the documentation, I create a sample site for testing. One of my requirements is to ensure that SOME pages required an authenticated user and some others, like the home page is not required. I specified the <deny users="?" /> on the web.config, but this is causing ALL pages require...
6
517
by: Manny Chohan | last post by:
I am using forms authetication in the web config. i can validate a user against a database and click on images which makes hidden panels visible.However when i click on the link inside a panel which should take user to another pages, it defaults them back to the login page prompting them to enter username and password. Could someone please...
3
3004
by: Stu Lock | last post by:
Hi, Is there a way of requiring a log in for individual asp.net pages rather than securing a entire directory. I have a web app where there are 100+ pages but only 2 need to be password protected. I am currently using forms authentication to block the entire folder: <authentication mode="Forms"> <forms name=".MYCOOKIE"...
4
1215
by: matthias s. | last post by:
Hi there, I'm creating a web app which consists of pages, that can seen by all (even anonymous) users. For example, we have a messageboard. The individual threads can be read by all users, but a new thread can only be added by a registered member. Is forms based authentication feasable here? How would I set it up? Put all the pages...
5
3533
by: Rory Becker | last post by:
Having now created a Custom MembershipProvider that seems to work correctly with my Logon and ChangePassword controls, I am, as they say, a happy bunny. The next stange is to move on to the creation of content which adjusts based on the user. I have several pages which require a user to be logged on and several which do not. Prior to this...
0
7408
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7661
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7815
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7433
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7763
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3458
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1891
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
712
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.