‘System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failedhttp://forums.asp.net/t/1259134.aspx/1?+System+Net+WebPermission+System+Version+2+0+0+0+Culture+neutral+PublicKeyToken+b77a5c561934e089+failedThu, 24 Dec 2009 01:26:32 -050012591342348543http://forums.asp.net/p/1259134/2348543.aspx/1?+System+Net+WebPermission+System+Version+2+0+0+0+Culture+neutral+PublicKeyToken+b77a5c561934e089+failed‘System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed <p class="MsoNormal" style="margin:0cm 0cm 0pt"><font face="Times New Roman" size="3">Hi,<br> </font></p> <font face="Times New Roman" size="3">&nbsp;</font><span lang="EN-GB" style=""><font size="3"><font face="Times New Roman">Im having a problem that has me going out of my mind.&nbsp;<br> <br> </font></font></span><span lang="EN-GB" style=""><font size="3"><font face="Times New Roman">Heres whats happening:</font></font></span><span lang="EN-GB" style=""><font face="Times New Roman" size="3">&nbsp;</font></span><span lang="EN-GB" style=""><font size="3"><font face="Times New Roman">Im invoking a web service (WS) from an aspx page. Then that WS&nbsp;calls a SAP WS that is in a different machine. The first WS is published in a virtual directory in the default web site of IIS (Windows Server 2003) with Integrated Windows Authentication. The request gets threw to the first WS successfully&nbsp;and when I run debug I see that Im authenticated when I get there. The problem is when, in the first WS,&nbsp;I request a new set of credentials to access the SAP WS. It gives me the following exception:</font></font></span><span lang="EN-GB" style=""><font face="Times New Roman" size="3">&nbsp;<br> <br> </font></span><span lang="EN-GB" style=""></span><span lang="EN-GB" style=""><font size="3"><font face="Times New Roman">Request for the permission of type System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed</font></font></span><span lang="EN-GB" style=""><font face="Times New Roman" size="3">&nbsp;<br> <br> </font></span><span lang="EN-GB" style=""><font size="3"><font face="Times New Roman">More specifically, it gives me the following exceptions in this line of code:</font></font></span><span lang="EN-GB" style=""><font face="Times New Roman" size="3">&nbsp;<br> <br> </font></span><span lang="EN-GB" style=""></span><span lang="EN-GB" style=""></span><span lang="EN-GB" style="font-size:10pt; font-family:'Courier New'">bapiVendorGetDetailService.Credentials = <span style="color:blue">New</span> System.Net.NetworkCredential(username, password)</span><span lang="EN-GB" style=""></span><span lang="EN-GB" style=""><font face="Times New Roman" size="3">&nbsp;<br> <br> </font></span><span lang="EN-GB" style=""></span><span lang="EN-GB" style=""><font size="3"><font face="Times New Roman">Domain - Request for the permission of type System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.<br> <br> </font></font></span> <p class="MsoNormal" style="margin:0cm 0cm 0pt"><span lang="EN-GB" style=""><font size="3"><font face="Times New Roman">Password - Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.<br> </font></font></span></p> <span lang="EN-GB" style=""><font size="3"><font face="Times New Roman">Username - Request for the permission of type System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.</font></font></span><span lang="EN-GB" style=""><font face="Times New Roman" size="3">&nbsp;<br> <br> </font></span><span lang="EN-GB" style=""><font size="3"><font face="Times New Roman">The code I use to call the first WS is this:</font></font></span><span lang="EN-GB" style=""><font face="Times New Roman" size="3">&nbsp;<br> <br> </font></span><span lang="EN-GB" style=""></span><span lang="EN-GB" style=""></span><span lang="EN-GB" style="font-size:10pt; color:blue; font-family:'Courier New'">Dim</span><span lang="EN-GB" style="font-size:10pt; font-family:'Courier New'"> sapWS <span style="color:blue">As</span> <span style="color:blue">New</span> WSSAP.Service1<br> </span><span lang="EN-GB" style="font-size:10pt; font-family:'Courier New'">sapWS.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials</span><span style="font-size:10pt; color:blue; font-family:'Courier New'"></span> <p class="MsoNormal" style="margin:0cm 0cm 0pt"><span style="font-size:10pt; color:blue; font-family:'Courier New'">Dim</span><span style="font-size:10pt; font-family:'Courier New'"> vendorName <span style="color:blue">As</span> <span style="color:blue">String</span> = sapWS.GetVendorName(<span style="color:maroon">&quot;0000100002&quot;</span>)</span></p> <font face="Times New Roman" size="3">&nbsp;</font> <p class="MsoNormal" style="margin:0cm 0cm 0pt"><span lang="EN-GB" style=""><font size="3"><font face="Times New Roman">The funny thing is that when I access the WS threw the asmx page, everything works just fine.</font></font></span></p> <p class="MsoNormal" style="margin:0cm 0cm 0pt"><span lang="EN-GB" style=""><font size="3"><font face="Times New Roman"></font></font></span>&nbsp;</p> <p class="MsoNormal" style="margin:0cm 0cm 0pt"><span lang="EN-GB" style=""><font size="3"><font face="Times New Roman">I don't know if what&nbsp;I said was confusing. I hope not because I can really use the help</font></font></span></p> <span lang="EN-GB" style=""><font face="Times New Roman" size="3">&nbsp;</font></span> <p class="MsoNormal" style="margin:0cm 0cm 0pt"><span lang="EN-GB" style=""><font size="3"><font face="Times New Roman">Thanks in advance</font></font></span></p> 2008-05-09T15:53:02-04:002353723http://forums.asp.net/p/1259134/2353723.aspx/1?Re+System+Net+WebPermission+System+Version+2+0+0+0+Culture+neutral+PublicKeyToken+b77a5c561934e089+failedRe: ‘System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed <p>Hi</p> &lt;div&gt; <p>&nbsp;By default, the &quot;security&quot; permission set that is applied to the internet zone does not allow calls to unmanaged code, So you need to adjust&nbsp;trust level of your app (and any .dlls you made with it)&nbsp;using .NET Framework Configuration Tool.</p> Try to config .Net framework permission set to &quot;Full Access&quot; on the Runtime Security Policy --&gt; Machine --&gt; Code Groups --&gt;All_Code --&gt; Right-click the appropriate code group and select Properties.-&gt; Click the Permission Set tab. -&gt; Associate&nbsp;FullTrust permission set to code group from the drop-down list and click OK.&lt;/div&gt; <p>Hope it helps</p> 2008-05-13T07:07:11-04:002354077http://forums.asp.net/p/1259134/2354077.aspx/1?Re+System+Net+WebPermission+System+Version+2+0+0+0+Culture+neutral+PublicKeyToken+b77a5c561934e089+failedRe: ‘System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed <p>It didn't work. I tried to set full trust at all code groups and it also didn't work.</p> <p>Something I forgot to mention was that I've already tried to run this while&nbsp;the caspol security was&nbsp;off (with the command caspol -s off) and it also didn't work.</p> <p>Any more ideas? Is it possible that this is not a security problem? I find this very odd due to the nature of the exceptions.</p> 2008-05-13T09:55:24-04:002357703http://forums.asp.net/p/1259134/2357703.aspx/1?Re+System+Net+WebPermission+System+Version+2+0+0+0+Culture+neutral+PublicKeyToken+b77a5c561934e089+failedRe: ‘System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed <p align="left">Got it!</p> <p align="left">I just added these lines to my web.config file and it worked.</p> <font color="#0000ff" size="2">&lt;</font><font color="#a31515" size="2">location</font><font color="#0000ff" size="2"> </font><font color="#ff0000" size="2">allowOverride</font><font color="#0000ff" size="2">=</font><font size="2">&quot;</font><font color="#0000ff" size="2">false</font><font size="2">&quot;</font><font color="#0000ff" size="2">&gt;</font><font color="#0000ff" size="2"> <blockquote dir="ltr" style="margin-right:0px"> <p>&lt;</font><font color="#a31515" size="2">system.web</font><font color="#0000ff" size="2">&gt;</p> <blockquote dir="ltr" style="margin-right:0px">&lt;</font><font color="#a31515" size="2">trust</font><font color="#0000ff" size="2"> </font><font color="#ff0000" size="2">level</font><font color="#0000ff" size="2">=</font><font size="2">&quot;</font><font color="#0000ff" size="2">Full</font><font size="2">&quot;</font><font color="#0000ff" size="2"> </font><font color="#ff0000" size="2">originUrl</font><font color="#0000ff" size="2">=</font><font size="2">&quot;&quot;</font><font color="#0000ff" size="2"> /&gt;</font><font color="#0000ff" size="2"></blockquote> <p>&lt;/</font><font color="#a31515" size="2">system.web</font><font color="#0000ff" size="2">&gt;</p> </blockquote> <p>&lt;/</font><font color="#a31515" size="2">location</font><font color="#0000ff" size="2">&gt;</font></p> 2008-05-14T15:50:55-04:002369266http://forums.asp.net/p/1259134/2369266.aspx/1?Re+System+Net+WebPermission+System+Version+2+0+0+0+Culture+neutral+PublicKeyToken+b77a5c561934e089+failedRe: ‘System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed <p>Hi guys,</p> <p>Everything done, but for the security is not sure.</p> <p>Visit Article: </p> <span style="color:#1f497d"><a href="http://store.bamboosolutions.com/kb/article.aspx?id=10405"><font face="Calibri" size="3">http://store.bamboosolutions.com/kb/article.aspx?id=10405</font></a></span> 2008-05-20T17:07:52-04:003581543http://forums.asp.net/p/1259134/3581543.aspx/1?Re+System+Net+WebPermission+System+Version+2+0+0+0+Culture+neutral+PublicKeyToken+b77a5c561934e089+failedRe: ‘System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed <p>In WPF browser application&nbsp;follow given steps to give full trust permission</p> <p>1. Select project</p> <p>2.&nbsp;Right click and select properties.</p> <p>3. Select&nbsp;security tab from left panel.</p> <p>4. Now select/ check the radio button that says &quot; This is full trust application&quot;<br> <br> 5. Save and run application. </p> <p>This will&nbsp;solve ur problem of permission on <strong>System.Net.WebPermission</strong>.<br> &nbsp;</p> 2009-12-24T01:26:32-05:00