freelanceprogrammers.org Forum Index » ASP

Re: creating a header


View user's profile Post To page top
colemantrugby Posted: Fri Jan 07, 2005 11:59 pm


Joined: 31 Dec 2004

Posts: 2
Re: creating a header
Trent,

As it so happens, I`ve been wrestling with this for the past day. If you come
up with the answer, I`m very interested. A few leads for you:

You can create your own web request and set credentials on it. See
System.Net.WebRequest, System.Net.NetworkCredential, and
System.Net.CredentialCache.
http://www.codeproject.com/csharp/HttpWebRequest_Response.asp

The problem, as I`ve discovered, is that lets me get one request across. Now,
if I click on a link on the page that I now bring up (page in the protected
area), I generate a _new_ request. And need to authenticate again... So, so
long as you only need something off one page, you`re great with this stuff. If,
as I suspect, you need to do more, I`m very interested in what answers you find
out.


Working code below (note my site uses Basic authentication, rather than NTLM )
NetworkCredential myCred = new NetworkCredential("username", "password");

CredentialCache myCache = new CredentialCache();

myCache.Add(new Uri("http://localhost/TestHTTPS"), "Basic", myCred);

WebRequest webRequest =
HttpWebRequest.Create("http://localhost/TestHTTPS/WebForm2.aspx");

webRequest.Credentials = myCache;


WebResponse webResponse = webRequest.GetResponse();

webResponse.Close();

Server.Execute("WebForm2.aspx"); // I now have the credentials from
above, and can execute my original request

----- Original Message -----
From: Falls, Travis D (HTSC, CASD)
To: `AspNetAnyQuestionIsOk@yahoogroups.com`
Sent: Friday, January 07, 2005 12:44 PM
Subject: [AspNetAnyQuestionIsOk] creating a header


Can someone point me to a tutorial that will show me how to create a header
to authenticate to a windows protected site (NTML). I have a valid user id
and password I just don`t know how to put the header together to automate
login.

Travis D. Falls |Consultant, Raft.Net IT | 860.547.4070 |
travis.falls@...



-----Original Message-----
From: scaevola637 [mailto:scaevola637@...]
Sent: Friday, January 07, 2005 12:41 PM
To: AspNetAnyQuestionIsOk@yahoogroups.com
Subject: [AspNetAnyQuestionIsOk] Re: Sticky Wicket: C#.NET calling ADODB



HERE is one function that needs converting from vbscript to C#.
the namespace is ADODB, which is guess is what everyone used in
Classic ASP before ASP.NET. I guess I need a book on Classic ADO.
The instructions are to Keep using ADO but rewrite into C#.NET. I
am not sure it can be done.

function OpenAFCPT()
set adoAFCPT = server.createobject("ADODB.Connection")
adoAFCPT.commandtimeout = dbCommandTimeOut
adoAFCPT.open dnsAFCPT, usrAFCPT, pasAFCPT
set cmdAFCPT = Server.CreateObject("ADODB.Command")
cmdAFCPT.ActiveConnection = adoAFCPT
cmdAFCPT.CommandTimeout = dbCommandTimeOut
cmdAFCPT.CommandType = adCmdStoredProc

end function







Yahoo! Groups Links








This communication, including attachments, is for the exclusive use of
addressee and may contain proprietary, confidential or privileged
information. If you are not the intended recipient, any use, copying,
disclosure, dissemination or distribution is strictly prohibited. If
you are not the intended recipient, please notify the sender
immediately by return email and delete this communication and destroy all
copies.



------------------------------------------------------------------------------
Yahoo! Groups Links

a.. To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

b.. To unsubscribe from this group, send an email to:
AspNetAnyQuestionIsOk-unsubscribe@yahoogroups.com

c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



[Non-text portions of this message have been removed]
Reply with quote
Send private message
View user's profile Post To page top
travis.falls@... Posted: Sat Jan 08, 2005 12:09 am


Joined: 10 Jan 2006

Posts: 33
Re: creating a header
Tina,
Have you tried simply re-packing the header for every request? I wonder
what is set in the header to say... "Hey, no worries, I am already
authenticated". I will keep you in the loop on my progress with this;
thanks for sharing your leads.

Travis D. Falls |Consultant, Raft.Net IT | 860.547.4070 |
travis.falls@...



-----Original Message-----
From: Tina [mailto:tina@...]
Sent: Friday, January 07, 2005 1:00 PM
To: AspNetAnyQuestionIsOk@yahoogroups.com
Subject: Re: [AspNetAnyQuestionIsOk] creating a header


Trent,

As it so happens, I`ve been wrestling with this for the past day. If you
come up with the answer, I`m very interested. A few leads for you:

You can create your own web request and set credentials on it. See
System.Net.WebRequest, System.Net.NetworkCredential, and
System.Net.CredentialCache.
http://www.codeproject.com/csharp/HttpWebRequest_Response.asp

The problem, as I`ve discovered, is that lets me get one request across.
Now, if I click on a link on the page that I now bring up (page in the
protected area), I generate a _new_ request. And need to authenticate
again... So, so long as you only need something off one page, you`re great
with this stuff. If, as I suspect, you need to do more, I`m very interested
in what answers you find out.


Working code below (note my site uses Basic authentication, rather than NTLM
)
NetworkCredential myCred = new NetworkCredential("username", "password");

CredentialCache myCache = new CredentialCache();

myCache.Add(new Uri("http://localhost/TestHTTPS"), "Basic", myCred);

WebRequest webRequest =
HttpWebRequest.Create("http://localhost/TestHTTPS/WebForm2.aspx");

webRequest.Credentials = myCache;


WebResponse webResponse = webRequest.GetResponse();

webResponse.Close();

Server.Execute("WebForm2.aspx"); // I now have the credentials from
above, and can execute my original request

----- Original Message -----
From: Falls, Travis D (HTSC, CASD)
To: `AspNetAnyQuestionIsOk@yahoogroups.com`
Sent: Friday, January 07, 2005 12:44 PM
Subject: [AspNetAnyQuestionIsOk] creating a header


Can someone point me to a tutorial that will show me how to create a
header
to authenticate to a windows protected site (NTML). I have a valid user
id
and password I just don`t know how to put the header together to automate
login.

Travis D. Falls |Consultant, Raft.Net IT | 860.547.4070 |
travis.falls@...



-----Original Message-----
From: scaevola637 [mailto:scaevola637@...]
Sent: Friday, January 07, 2005 12:41 PM
To: AspNetAnyQuestionIsOk@yahoogroups.com
Subject: [AspNetAnyQuestionIsOk] Re: Sticky Wicket: C#.NET calling ADODB



HERE is one function that needs converting from vbscript to C#.
the namespace is ADODB, which is guess is what everyone used in
Classic ASP before ASP.NET. I guess I need a book on Classic ADO.
The instructions are to Keep using ADO but rewrite into C#.NET. I
am not sure it can be done.

function OpenAFCPT()
set adoAFCPT = server.createobject("ADODB.Connection")
adoAFCPT.commandtimeout = dbCommandTimeOut
adoAFCPT.open dnsAFCPT, usrAFCPT, pasAFCPT
set cmdAFCPT = Server.CreateObject("ADODB.Command")
cmdAFCPT.ActiveConnection = adoAFCPT
cmdAFCPT.CommandTimeout = dbCommandTimeOut
cmdAFCPT.CommandType = adCmdStoredProc

end function







Yahoo! Groups Links








This communication, including attachments, is for the exclusive use of
addressee and may contain proprietary, confidential or privileged
information. If you are not the intended recipient, any use, copying,
disclosure, dissemination or distribution is strictly prohibited. If
you are not the intended recipient, please notify the sender
immediately by return email and delete this communication and destroy all
copies.



----------------------------------------------------------------------------
--
Yahoo! Groups Links

a.. To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

b.. To unsubscribe from this group, send an email to:
AspNetAnyQuestionIsOk-unsubscribe@yahoogroups.com

c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.




[Non-text portions of this message have been removed]




Yahoo! Groups Links
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help