473,804 Members | 2,096 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 1174

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
5379
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
9507
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
6936
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
1645
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
6907
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
1462
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
9715
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10600
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
10352
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
10354
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
10097
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
9175
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
4313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3835
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
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.