PC Review


Reply
Thread Tools Rate Thread

how to access site content after authentication

 
 
ALA
Guest
Posts: n/a
 
      6th Oct 2007
Hello,

I've got the following problem: I would like to programmatically read
the content of a XHTML page that is only accessible by authorized
users after a specific user has passed the authorization
(authentication mode: forms). So let's say I've got a site
"login.aspx" where the user logs in, another site "page1.aspx" in a
directory "mydir" that is only accessible by authenticated users and
another site "page2.aspx" in the same directory where I want to load
the xhtml output from page1.aspx, e.g. by using
XmlDocument.load("http://myserver.com/mydir/page1.aspx").

Unfortunately, the loaded XmlDocument only contains the content of the
login page "login.aspx" which is logical for me because the ASP.NET
user is different from the user that logged in some minutes before. On
the other hand, the human user is still logged in and can access
"page1.aspx" whenever he wants by clicking on a certain link inside
the browser side.

So my question ... is there a way how I can access the user-dependent
data from "page1.aspx" from the code of "page2.aspx" with the
authentication information of the human user that's authenticated,
e.g. by using the Response.Body - Property or something like that?
Maybe it's too easy so that I cannot see a solution ... or also
impossible. Thanks for the help.

Background is that I want to write a Semantic Web application where
page2.aspx has to read the RDFa content of page1.aspx ...

Andre

 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      6th Oct 2007
You would need to log in by making a form post identical to the one at the
Login page, and pass the cookie Collection with your subsequent requests, as
it contains the cookie with the FormsAuthentication Ticket.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com



"ALA" wrote:

> Hello,
>
> I've got the following problem: I would like to programmatically read
> the content of a XHTML page that is only accessible by authorized
> users after a specific user has passed the authorization
> (authentication mode: forms). So let's say I've got a site
> "login.aspx" where the user logs in, another site "page1.aspx" in a
> directory "mydir" that is only accessible by authenticated users and
> another site "page2.aspx" in the same directory where I want to load
> the xhtml output from page1.aspx, e.g. by using
> XmlDocument.load("http://myserver.com/mydir/page1.aspx").
>
> Unfortunately, the loaded XmlDocument only contains the content of the
> login page "login.aspx" which is logical for me because the ASP.NET
> user is different from the user that logged in some minutes before. On
> the other hand, the human user is still logged in and can access
> "page1.aspx" whenever he wants by clicking on a certain link inside
> the browser side.
>
> So my question ... is there a way how I can access the user-dependent
> data from "page1.aspx" from the code of "page2.aspx" with the
> authentication information of the human user that's authenticated,
> e.g. by using the Response.Body - Property or something like that?
> Maybe it's too easy so that I cannot see a solution ... or also
> impossible. Thanks for the help.
>
> Background is that I want to write a Semantic Web application where
> page2.aspx has to read the RDFa content of page1.aspx ...
>
> Andre
>
>

 
Reply With Quote
 
ALA
Guest
Posts: n/a
 
      6th Oct 2007
hmhmm, so there seems to be no way to make something like

WebRequest request = WebRequest.Create(url);

>> request.Credentials = {the authentication information

of the user who just logged in} <<

HttpWebResponse response =
(HttpWebResponse)request.GetResponse();
Stream dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();

XmlDocument xml = new XmlDocument();
xml.LoadXml(responseFromServer);

?

thanks a lot

Andre

 
Reply With Quote
 
ALA
Guest
Posts: n/a
 
      7th Oct 2007
ok, I got it working...

the cue was that the FormsAuthentication.FormsCookieName property
holds the cookie name of the authenticated user.

HttpWebRequest request =
(HttpWebRequest)WebRequest.Create(url);
request.CookieContainer = new CookieContainer();

HttpCookie authCookie =
HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName];
request.CookieContainer.Add(new Cookie(authCookie.Name,
authCookie.Value, authCookie.Path, "localhost"));

HttpWebResponse response =
(HttpWebResponse)request.GetResponse();

maybe this'll also help somebody else in the future...

André

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Authentication Vista Ulitimate IIS 7.0 site access J.R. Windows Vista Security 1 20th Jan 2009 04:32 AM
RAS site to site vpn User Authentication StinkyDuck Microsoft Windows 2000 RAS Routing 7 8th Dec 2008 02:57 AM
Re: Authentication and user based content Eliyahu Goldin Microsoft ASP .NET 2 14th Apr 2008 04:11 PM
Re: Authentication and user based content Cowboy \(Gregory A. Beamer\) Microsoft ASP .NET 0 14th Apr 2008 02:45 PM
asp.net forms authentication for all content Paul Cowan Microsoft ASP .NET 1 23rd Apr 2004 11:20 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:34 PM.