Solved

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

Posted on 2017-01-27
6
78 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

728 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