Problem using webclient : (illegal characters in Path) error - TechRepublic
Question
April 28, 2008 at 10:57 PM
kiran.beladiya

Problem using webclient : (illegal characters in Path) error

by kiran.beladiya . Updated 18 years, 2 months ago

I am facing problem while making web request by WebClient.
I am making request to google map geocode apge to findout the longitude and latitude of particular address.
Here is my code to do that :

Dim QueryString As String
Dim responseText As String = “”
Dim WC As New Net.WebClient
Dim SR As IO.StreamReader

QueryString = “?q=” & getValidAddressString() & “&output=csv&key=” & ConfigurationManager.AppSettings(“GeoCodeKey”)

Dim redirectURL As String = ConfigurationManager.AppSettings(“GeoCodeURL”) & QueryString

SR = New IO.StreamReader(WC.OpenRead(redirectURL))

responseText = SR.ReadToEnd()
SR.Close()
processResponseText(responseText)

The strange thing is that for same address string, the code is working without any problem in one page. While the same code(have copy pasted) in another page is throwing the following error :

Illegal characters in path.

Exception Details: System.ArgumentException

at System.Security.Permissions.FileIOPermission.HasIllegalCharacters(String[] str)
at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, String[] pathList, Boolean checkForDuplicates, Boolean needFullPath)
at System.IO.Path.GetFullPath(String path)
at System.Net.WebClient.GetUri(String path)
at System.Net.WebClient.DownloadData(String address)
at KG.GeoCodeHelper.Page_Load(Object sender, EventArgs e) in

This discussion is locked

All Comments