473,464 Members | 1,729 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 5200
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.