473,322 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

System.Security.SecurityException

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
Nov 21 '05 #1
1 5188
Problem was that the site I was posting to was different to the hosting
site!

I needed to add permissions

control panel - Administrative Tools - Microsoft .NET Framework 1.1
Configuration - Runtime Security Policy - Machine - Code Groups - All_Code -
Trusted_Zone
Then Right-click Trusted_Zone, and then click New

Name = test

Condition = Zone

Zone = Trusted

Permission = full trust

Click Finish

Add hosting site to trusted sites

"Adrian" <Ad****@nospamhotmail.com.uk> wrote in message
news:cs**********@sparta.btinternet.com...
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

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sam | last post by:
I have a desktop VB.Net application I developed locally. I uploaded it to a file server we have and the .Net Framework is installed on the file server. When I try to run the executable from the...
0
by: James B | last post by:
OMA (Outlook Mobile Access) under Exchange is giving me a System.Security.SecurityException error. From what I gather this is a problem with the security level under which the OMA application is...
2
by: MFRASER | last post by:
I am getting a System.Security.SecurityException when I try and laod a dataset from an xml file any ideas on what would cause this? System.Security.SecurityException' occurred in mscorlib.dll ...
1
by: edge | last post by:
hi, here it is my problem. My console app, reads a text file where it grabs username/password. Next, my app creates a .BAT file to trigger the command ftp:\\user:password@ftphomeaddress. ...
0
by: Luis Esteban Valencia | last post by:
Hello I have this error when I submit the page with the following code. I had never see this kind of errors. Thanks private void btnsubmit_Click(object sender, System.EventArgs e) { ...
3
by: steveeisen | last post by:
microsoft.public.dotnet.languages.vb.upgrade isn't getting much traffic, so I'll try here. Ours is a VB6 shop exploring .NET. First I wrote a new application with VB .NET 2003 to create a...
0
by: Lambuz | last post by:
Hi all, I've got this problem. I've to implemente a solution like the example in http://support.microsoft.com/default.aspx?scid=kb;EN-US;313891, but I can't configure correctly the example. ...
4
by: stephen | last post by:
Hi, I am getting an error while trying to create an excel file. "Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the...
3
by: Mike | last post by:
Hi I have problem as folow: Caught Exception: System.Configuration.ConfigurationErrorsException: An error occurred loading a configuration file: Request for the permission of type...
4
by: confused1234 | last post by:
I get the error at the bottom of this post when i click on a linkbutton, javascript:__doPostBack('ctl00$Main$btnchangeemail','') The problem is intermitant, sometimes it works and sometimes...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.