Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: Forms Authication & Web Requests


Message #1 by "mark" <mark.towse@r...> on Tue, 19 Mar 2002 10:07:10
I am trying to create a web request to a forms authenticated web app.  I 
am using the code shown below:

Dim objWebRequest As WebRequest
Dim objWebResponse As WebResponse

objWebRequest = WebRequest.Create("http://localhost/fold/Page.aspx")

objWebRequest.PreAuthenticate = True

objWebRequest.Credentials = CredentialCache.DefaultCredentials

objWebResponse = objWebRequest.GetResponse

The code works fine when I am using it to create a request to a windows 
authenticated web form but when I try to call an app that uses forms 
authentication with deny users=??? it doesn?t work.  It doesn?t cause a 
webexceptionstatus.protocolerror (401Unauthorized) error, which I might of 
expected but it also doesn?t create the temp files in the 
WINNT/Microsoft.NET/Temporary ASP.NET/Files/AppName/tempfiles which I want 
it to create.  If I set authorization to allow users=??? with forms 
authentication then it does work and the temp files are created.  This 
suggests to me that when I am creating my web request it is trying to 
access my web forms as an anonymous user.  Is there anyway I can 
authenticate the request so that I can use forms authentication with deny 
users=???.

Cheers


  Return to Index