hi
I'm attempting to build an app then sends a request to a URL and reads the
response it works fine on my test site but when I connect to a real system I
get the text below, I guess its responding to a request from the remote end
if so how do I either tell it to ignore the request and just send the url or
set what its looking for?
If type the same url in the address bar of IE it works without requesting
any permissions!
the code used to send the request is at the bottom.
Help!!!!
************** Exception Text **************
System.Security.SecurityException: Request for the permission of type
System.Net.WebPermission, System, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089 failed.
at System.Security.CodeAccessSecurityEngine.CheckHelp er(PermissionSet
grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
PermissionToken permToken)
at System.Security.CodeAccessSecurityEngine.Check(Per missionToken
permToken, CodeAccessPermission demand, StackCrawlMark& stackMark, Int32
checkFrames, Int32 unrestrictedOverride)
at System.Security.CodeAccessSecurityEngine.Check(Cod eAccessPermission
cap, StackCrawlMark& stackMark)
at System.Security.CodeAccessPermission.Demand()
at System.Net.HttpRequestCreator.Create(Uri Uri)
at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)
at System.Net.WebRequest.Create(String requestUriString)
at myControl1.myControl.LoadURL(String Url)
at myControl1.myControl.Button1_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage (Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(M essage& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)
the code that is sending the request follows and URL is set to the following
format http://awebsite/abc?id=1234?data=12345
Public Function LoadURL(ByVal Url As String) As String
Try
Dim wrq As WebRequest = WebRequest.Create(Url)
Dim wrp As HttpWebResponse = _
DirectCast(wrq.GetResponse(), HttpWebResponse)
Dim sr As New StreamReader(wrp.GetResponseStream)
Dim Text As String = sr.ReadToEnd()
wrq.Timeout = 30
Return Text
sr.Close()
wrp.Close()
Catch e As WebException
Console.WriteLine(e.Message)
Return e.Status.ToString
If e.Status = WebExceptionStatus.ProtocolError Then
Console.WriteLine("Status Code : {0}", CType(e.Response,
HttpWebResponse).StatusCode)
Console.WriteLine("Status Description : {0}", CType(e.Response,
HttpWebResponse).StatusDescription)
End If
End Try
Return Text
End Function