473,787 Members | 2,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

webrequest and authentication problem

Dear ASP.NET Programmers,

Please consider the intranet site with the following forms authentication
page http://localhost/database/login.aspx. The usernames and passwords are
stored in the SQL Server database. After authenticating, the users are be
able to save the generated documents (HTML output of the generated document)
when they click on a button in http://localhost/database/medicalDocs/1.aspx.
I use the following code:

Dim wReq As WebRequest
Dim wResp As WebResponse
Dim srData As StreamReader
Dim fsDest As FileStream
Dim wrStream As StreamWriter
Dim buffer(1024) As Char
Dim intBytes As Integer
Dim strData As String

fsDest = New FileStream("d:\ Downloads\doc.h tm",
FileMode.OpenOr Create, FileAccess.Writ e)
wrStream = New StreamWriter(fs Dest)
wReq =
WebRequest.Crea te("http://localhost/database/medicalDocs/1.aspx")
wResp = wReq.GetRespons e
srData = New StreamReader(wR esp.GetResponse Stream,
System.Text.Enc oding.ASCII)
intBytes = srData.Read(buf fer, 0, 1024)
Do While (intBytes > 0)
wrStream.Write( buffer, 0, intBytes)
intBytes = srData.Read(buf fer, 0, 1024)
Loop
wrStream.Close( )
srData.Close()
fsDest.Close()

but the saved document is the login page
(http://localhost/database/login.aspx) instead of the
http://localhost/database/medicalDocs/1.aspx. How can I supply the login
information with the WebRequest object or how can I work around it? Thanks
in advance,
Nov 20 '05 #1
0 1167

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

Similar topics

17
7240
by: James Johnson | last post by:
Dear C#dex, I define a variable: HttpWebRequest webRequest and run the following request webRequest = WebRequest.Create(TARGET_URL) as HttpWebRequest; The webRequest object returns values and in the debugger I can see the value I want in the property
5
17577
by: Tony | last post by:
Please help, I've scoured the web but cannot find an answer to this! I want to use WebRequest to get the contents of a web page. The trouble is, the page require you to go to a login page (using ASP - not ASP.NET), and enter a username and password to get in. How do I use WebRequest in this situation? I cannot find any way of supplying the username and password. The '.Credentials' does not work because that is only for Windows...
2
2222
by: TheBurgerMan | last post by:
Hi all. I need to attach NetworkCredentials to a WebRequest and display the resulting web page in an IFRAME (aspx). I have validated that I can get the page (using the NetworkCredentials), but how do I pump the data into an IFRAME to display too the user? I have tried accessing the web page directly from the IFRAME, but the network credentials keep popping up and I cannot see how to set the NetworkCredentials to the SRC of the IFRAME....
2
3969
by: Stephen Miller | last post by:
I have an ASPX report and I want to capture the rendered HTML and write to a file on the webserver. Several posts suggest using WebRequest to make a second call to the page, and screen-scrape the resulting HTML. The technique typically described is: '-- Get the current URL and request page Dim url As String = System.Web.HttpContext.Current.Request.Url.AbsoluteUri Dim req As System.Net.WebRequest = System.Net.WebRequest.Create(url)
8
2405
by: John K. | last post by:
Hi I was wondering if it's possible to use the WebRequest class to access a file on windows shared folder with authentication? If yes, what would the syntax be? I've tried to look this up in the references available but to no avail Also, is it safer (better practise) in an LAN environment to use HTTP requests to access shared files (via ASP.NET) rather than UNC file shares TIA Regards John
4
7235
by: Terry | last post by:
Hello, I am trying to get a response for an .aspx page in my current project (same virtual directory) by using WebRequest.GetResponse but I keep getting a exception with "500 Internal server error" in the exception message. I am able to do this fine with another .aspx page that has no code-behind. The page that has code-behind throws the exception. What I am doing is getting the .aspx response, reading the stream, replacing
0
1110
by: IronYuppie | last post by:
Hi all-- I'm retrieving contents from my site using the retrieving images from the database method listed here: http://www.aspfree.com/c/a/ASP.NET/Retrieving-Images-from-a-Database--C---Part-II/ Basically, the page just returns the image into the page (also within the same site) that's calling it.
2
6470
by: davidcbrown | last post by:
I started using .NET 2003 and my first application is to parse an HTML form. But I am behind an ISA firewall and get "(407) Proxy Authentication Required" with the following code. The proxy settings in webReq.Proxy appear to be OK, even without setting them as below. IE works, but this does not. Any ideas? (or where to ask?) -- David Dim webReq As WebRequest = WebRequest.Create(txtUrl.Text) webReq.Proxy = WebProxy.GetDefaultProxy Dim...
1
1637
by: Bruno | last post by:
Hello friends I'm developing a app o send xml data to a web server using HTTP POST.To do that Im using the WebRequest VB class. I can send the data sucessfully to the web server, using: Dim req As WebRequest req = WebRequest.Create("http://localhost/SendAndReceiveDataWebPages/PassText.aspx") req.Method = "POST"
0
9498
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10172
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5398
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.