473,796 Members | 2,544 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Prevent NetworkCredenti al caching

Hi

We have an application that send webRequests to a server using a specified
user accounts. These requests will often be for different users.

The problem we have is that the webRequest, even though it is a fresh object
that is disposed of, will always use the first newtowrkCrednti al we specify.
We are NOT using credentialCache as we dont want to cache the credentials.
Anyone know why this is and how to prevent / workaround this?

public sub test()

messageBox.Show (sendData("www. test.com/returnData.asp" ,"userA","passw ord",false,noth ing))

messageBox.Show (sendData("www. test.com/returnData.asp" ,"userB","passw ord",false,noth ing))

messageBox.Show (sendData("www. test.com/returnData.asp" ,"userC","passw ord",false,noth ing))
end sub

public function sendData(ByVal strUrl As String, ByVal strUser As String,
ByVal strPwd As String, ByVal blnPost As Boolean, ByVal strToSend As String)
as string
Dim webReader As System.IO.Strea mReader
Dim strResp As String
webReader = New System.IO.Strea mReader(streamP ostXML(strUrl,
strUser, strPwd, blnPost, strToSend))
strResp = webReader.ReadT oEnd()
return strResp
end function

Public Shared Function streamPostXML(B yVal strUrl As String, ByVal strUser
As String, ByVal strPwd As String, ByVal blnPost As Boolean, ByVal strToSend
As String) As System.io.Strea m
Dim webReq As System.Net.WebR equest
Dim webResp As System.Net.WebR esponse
Dim cred As System.Net.Netw orkCredential
Try
webReq = System.Net.WebR equest.Create(s trUrl)
If Not strUser Is Nothing Then
cred = New System.Net.Netw orkCredential(s trUser, strPwd)
webReq.Credenti als = cred
End If
If blnPost Then
webReq.Method = "POST"
Else
webReq.Method = "GET"
End If

If Not strToSend Is Nothing And strToSend <> "" Then
Dim reqStream As System.IO.Strea m
Try
'convert string into bytes so can write to a stream
Dim bytToPost() As Byte
bytToPost = System.Text.Enc oding.UTF8.GetB ytes(strToSend)
webReq.ContentL ength = bytToPost.Lengt h
reqStream = webReq.GetReque stStream
' Write encoded data into request stream
reqStream.Write (bytToPost, 0, bytToPost.Lengt h)
Finally
reqStream.Close ()
End Try
End If
'now we get the response and pass it into a stream reader and
read it
webResp = webReq.GetRespo nse
Return webResp.GetResp onseStream
Catch ex As Exception
Throw ex
Finally
webReq = Nothing
cred = Nothing
webResp = Nothing
End Try

End Function
Code is:

Nov 23 '05 #1
0 1173

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

Similar topics

3
5820
by: Santhi | last post by:
Hi, I wish to avoid caching asp pages at the user end . Currently I have declared Response.Expires=0 at the top of my asp page. I have also used the following meta tags to prevent client side caching <meta HTTP-EQUI="PRAGMA" CONTENT="NO-CACHE"></meta> but still the pages are cached at the client side. Any help or suggesstion would be greatly appreciated to fix this issue
14
5378
by: Ludwig77 | last post by:
I read that there are some tags that can be entered in a web page's meta tags in order to prevent web bot searching and indexing of the web page for search engines. What is the tagging that I would need to use?
10
9504
by: Behzad | last post by:
Hi all I'am ASP programmer and I have built a site that users can upload and download files.All things store in a DB and everytime someone enters a page,the application requery the Db and shows him data. but there is aproblem: all my pages caches before Client and i can not see fresh page.for example if I did some activity on Monday on Wed. i Still see the old page that was produced on Monday.I have put some header in BOth Html And ASP...
5
3139
by: R. Ian Lee | last post by:
I have an ASP.NET page that spawns a popup window using javascript's window.open. This works fine. It pops up, you enter some data, press save and everything saves as it should. But, if you click the button to open the popup again, then it opens with the values that were in it before the "save" was executed. I've determined that the problem is that IE is storing the page in it's local temporary internet files cache and isn't going to...
0
1542
by: Frankie | last post by:
When I want to prevent a page from being cached, I have been using the following directive: <%@ OutputCache Location="none" %> I have also seen a few other methods recommended to prevent page caching. like these... Response.Cache.SetCacheability(HttpCacheability.NoCache) Response.Cache.SetNoStore() Response.AppendHeader("Pragma", "no-cache");
3
6934
by: Patrick Fogarty | last post by:
I am programming what is to be a web service client that will use an HTTP-POST to request and retrieve data. The remote server (written in java for what it's worth) requires basic authentication as per RFC 2617 (http://www.faqs.org/rfcs/rfc2617.html). My attempts to authenticate are failing. The server requires the header to be present with the request. For security reasons, it will not reply in any way if the header is not present. ...
1
1644
by: Ronald S. Cook | last post by:
I have an ASPX page wherein I receive an ID of a file to play. http://localhost/fwi/mediaplayer.aspx?id=3 When I go to a browser and type in the above, it works fine. But when I change the 3 to a 4, it still plays the old song. I tried some lines of code to prevent caching, but so far nothing works.
9
6904
by: =?Utf-8?B?SmVmZiBCZWVt?= | last post by:
I'm working on a litigation web app where users will review images of case documents. One of the requirements is that we either prevent the images from being cached on the clients machine (in temp directory or anywhere else) or we encrypt the images somehow. I'm guessing that encryption will not work, but is there a way to prevent caching? Also, is there a way to prevent printing on a current page? We're already not showing the menu...
0
1461
by: helveticus | last post by:
I have a master/details configuration that includes multiple user controls. The details page is configured to cache data via VaryByCustom. This works fine. One of the user controls contains an image button. With caching turned on, the control remains "lame" since the control is only dynamically generated during the first access. My understanding is that page caching directive causes all page user controls to be implicitly cached as...
0
9528
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
10230
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...
0
10012
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...
0
9052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7548
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
6788
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
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2926
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.