Solved

VB.Net error: An exception occurred during a WebClient request

Posted on 2017-01-27
6
36 Views
Last Modified: 2017-04-19
Issue:            Trying to download files from a web server.

Problem:      Receive error: An exception occurred during a WebClient request.

Scenario:
I have developed a VB.Net app, which we call MEPIL.  In it, I read an html file that has href references in it to a website where I can download zip files from.  I am not a web or network person so there may be more information to tell you than I am and I just don’t know what it is.

Anyway, this process used to work.  Now it doesn’t.  Now I get the following error:

“An exception occurred during a WebClient request.
Error creating the Web Proxy specified in the ‘system.net/defaultProxy’ configuration settings.”

According to my boss, we don’t use a proxy.

I get this error depending on where I store the VB.Net executable.

If I store the VB.Net executable on our network file server (H:\) drive, then I get this error.  However, if I move the executable to my local PC and run it, it works.  In both instances I execute the executable from my PC (no remoting in to a server or anything).

Note: I have another open question regarding this VB.Net application related to permissions on a SQL Server stored procedure where similar observations are made, except opposite.  With that error, the executable runs successfully if the executable is stored on the H:\drive but it does not run successfully if it is stored my local PC.

Can anyone help me with this?

Thank you.

Tammy
0
Comment
Question by:Tammy Freeman
  • 4
  • 2
6 Comments
 
LVL 20

Accepted Solution

by:
darbid73 earned 500 total points
ID: 41983190
In the absence of some code my guess is that you have a Code Access Security CAS issue.  (Probably the answer to your other question too).  

Here is one link about the problem.

You will find a number of people advocating that running a program from a shared drive is a bad idea.

Next you talk about (H) drives etc.  Please understand that this letter H is just something windows does to make it easier for users.  When programing you are going to have to use the UNC path.  This is "\\ComputerName\SharedFolder\Resource"  See Universal Naming Convention.
0
 

Author Comment

by:Tammy Freeman
ID: 41985559
darbid73 -

Thank you for your response.  A couple of things:

1.  Yes, I know H drive is just a letter, but it is easier than giving the URL and, even though you don't know what company I work for or anything, I don't want to give out any more information than I have to so that I am not causing a security issue of any sort.

2.  I think your CAS reasoning makes sense.  I am just not sure how to solve it.  I found the following web page: http://www.codemag.com/article/0405031 but I can't find the .NET Framework 1.1 Configuration tool on my PC.  It is not in the Control Panel that I can find.  So, I can't see what the rights are, much less figure out how to work with them.

3.  The line of code that I am using that is failing is:

   My.Computer.Network.DownloadFile(strHREFParse, My.Settings.DownloadPath & "\" & strDownloadFile, strID, strPwd, False, 4000000, True)

Here is an example of the href command with identifying information stripped out:

            <dd><a href="https://www###.xxxxx.co.xxx/xxx/global/xxxxx/ssl/xxx/databook/00_data.zip" target="_blank">0.TSV DATA</a></dd>

I pull out the "https://www###.xxxxx.co.xxx/xxx/global/xxxxx/ssl/xxx/databook/00_data.zip" from it.

So, I think you have sent me in the right direction but I don't yet have a solution.  Any additional help you can give me would be appreciated.  If I need to provide any additional information, just ask.

Thank you.

Tammy
0
 
LVL 20

Assisted Solution

by:darbid73
darbid73 earned 500 total points
ID: 41988473
Hi Tammy,

using your numbering;

1. That is ok, but you need to talk in UNCs and not drive letters. Also see later as I think you still "shaky" on this point.
2.  I have to admit that if I had this problem I would have to do just as much research as you. In other words I am not an expert.  see here for getting the tool.
3. You say that it works on your local PC but not on a server PC -  both " My.Computer.Network" and "My.Settings.DownloadPath " will both be different in this case and I suspect the reason for the failure.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Tammy Freeman
ID: 41996304
Thank you for your help again Darbid73.  

You got me moving in the right direction.  I still don't have a solution, but I am looking into it.  I may not try to resolve this issue.  I may try to resolve my other issue.  I would rather run the app from a localhost/PC rather than the network anyway and this is the issue that fails on the network.

By the way, I do know the difference between drive letters and UNC.  As I said, in my question I was using a drive letter to represent the UNC so I didn't put a UNC out publicly, even if it is within our firewall.  In my code, however, I do use the UNC.  So, it isn't a UNC problem.  I understand why you thought it may be so I am not saying this as a negative on your comment.  Just letting you know.

I will close this and give credit when I resolve the issue.

I appreciate your help.

Thank you.

Tammy
0
 

Author Comment

by:Tammy Freeman
I hated to mark my comment as the best solution, but it explains what I did.  If I marked something else that didn't work someone would think it did work.
0
 

Author Closing Comment

by:Tammy Freeman
The reason I selected darbid as the best solution is because he advocated not running the app from a shared drive.  That is the route I went down.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question