[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2017-01-27
6
Medium Priority
?
292 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 2000 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 2000 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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
ID: 42099040
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
ID: 42099055
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

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Screencast - Getting to Know the Pipeline
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

834 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