why "Request for the permission of type System.Net.WebPermission..."
-
Thursday, April 20, 2006 4:45 AM
I create the WinFX XAML Browser Application in VS 2005,Windows 2003
and I use the code to get ftp request:
FtpWebRequest result = (FtpWebRequest)FtpWebRequest.Create(URI);
URI is a string like ftp://xx.xx.xx.xx/filename
and there is a exception:
###########################
Startup URI: D:\Project\ProjFxTest\FxTest\FxTest\bin\Debug\FxTest.xbap
Application Identity: file:///D:/Project/ProjFxTest/FxTest/FxTest/bin/Debug/FxTest.xbap#FxTest.application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3313429c40cbf6df, processorArchitecture=msil/FxTest.exe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3313429c40cbf6df, processorArchitecture=msil, type=win32System.Security.SecurityException: Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.Net.FtpWebRequest..ctor(Uri uri)
at System.Net.FtpWebRequestCreator.Create(Uri uri)
at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)
at System.Net.WebRequest.Create(String requestUriString)
at FxTest.ftpTool.GetRequest(String URI)
at FxTest.ftpTool.GetFileSize(String filename)
at FxTest.ftpTool.FtpFileExists(String filename)
at FxTest.FormFtp.FtpTest()
at FxTest.FormFtp..ctor()#####################
But the same code works in Windows Application and Console Application
Please help me!
Many thanks!
All Replies
-
Thursday, April 20, 2006 11:28 AMModerator
It's because of the security restrictions for Web Browser Applications, they can connect using HTTP (I'm not sure about FTP) only to the site of origin. So in your case the Web Browser Application must be originated from http://xx.xx.xx.xx/.
-
Friday, April 21, 2006 1:15 AM
Thank you for your reply.
I think this limitation makes it not convenient to develop some web applications
Now I use WebService
Thank you!
-
Wednesday, March 25, 2009 6:10 AM
if you get any exception like " Request for the permission of type 'System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' ..."
then check for the trust your application is having.
Even my application WPF browser application when trying to consume a java web serice had this problem and finally found that the project ( wpf) should have the full trust.
to make your application full strust follow the instructions.
1. select the project ---> right click and select properties
2. you will get all the properties listed. select --- > security tab from left panel.
3. now select/ check the radio button that says " This is full trust application"
4. save and run ur application. this should solve ur problem.
knln- Proposed As Answer by Manikandan_Loganayaki Thursday, May 07, 2009 9:41 AM
-
Thursday, May 07, 2009 9:42 AMMr knln
Thank you very much -
Wednesday, October 21, 2009 12:20 PMThanks Ravi
You step by step instructions helped me resolve the issues.
Thanks for your help
-
Friday, February 11, 2011 1:27 PM
thanks ravi, you solved my problem, you're the man...
regards,
os
-
Wednesday, March 16, 2011 2:42 AM
The issue still exists, the client accessing the XBAP page needs have framework 4.0 to get the security demand alert and frame work 3.5 will simply block and provide trust not enabled error message.
Any work around for this?
-
Tuesday, May 29, 2012 12:18 PM
Hi Mr Knln,
Thanks Very Much ! !
good Help.

