locked
System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission RRS feed

  • Question

  • User955217749 posted

    Hi everybody,
    I have killed lots of time to solve this issue, but no success! ;-(  Here is my issue:
    I gave to my client ASP.NET Web application. They use 2 machines to edit some of the pages and they need it to share it through the mapped drive (Z), that everyone has access to the project files and can edit them in Visual Web Developer 2008.  I placed the app source files to the mapped drive (Z).  They don’t  use IIS at all. They debug it with ASP.NET development Server. When I try to view the “aspx” page in Web Developer 2008 (option  “View in Browser”) or debug it (F5) I get this error:

    System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

    I tried to set the access code security in .Net configuration file on machine level (Intranet or Internet) . Maybe I didn’t set them right in the settings. In “Membership conditions” settings I used: i.e:“ http://111.111.111.111/D$” or "file://Z:/*"
    Then I ran :
     C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\caspol.exe -q -m -ag 1 -url file://z/* FullTrust -name "Z Drive"
    But no success!!! :-(

    Every time I start the project form the mapped drive I get warning:
    “The project location is not trusted”
    “Z:\appliction path….”
    Running the application may result in security exception when it attempts to perform actions which requires full trust
    Click OK to ignore or continue

    Any idea?  Please

     

    Wednesday, January 14, 2009 9:33 PM

Answers

  • User372121194 posted

    Hi,

    From your description, I understand that you put the website in remote share folder and we get that error message when we try to run it from VS, right?

    To resolve this issue, we can try to grant the FullTrust right to that share folder:

    1. On the Web server, open Administrative Tools, and then double-click Microsoft .NET Framework Configuration.
    2. Expand Runtime Security Policy, expand Machine, and then expand Code Groups.
    3. Right-click All_Code, and then click New.
    4. Select Create a new code group. Give your code group a relevant name, such as the name of the applications share. Click Next.
    5. In the Choose the condition type for this code group list, select URL.
    6. In the URL box, type the path of the share in the following format:
      file:////\\<VAR>computername</VAR>\<VAR>sharename</VAR>\*
      Note Replace <VAR>computername</VAR> with the name of the computer that is hosting the remote share. Replace <VAR>sharename</VAR> with the name of the share.
    7. Click Next. On the next page, select Use an existing permission set, and then select FullTrust.
    8. Click Next, and then click Finish.
    9. Restart Microsoft Internet Information Services (IIS) to restart the ASP.NET worker process.

    For more information, see http://support.microsoft.com/?id=320268

     

    I look forward to receiving your test results.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 19, 2009 1:13 AM

All replies

  • User372121194 posted

    Hi,

    From your description, I understand that you put the website in remote share folder and we get that error message when we try to run it from VS, right?

    To resolve this issue, we can try to grant the FullTrust right to that share folder:

    1. On the Web server, open Administrative Tools, and then double-click Microsoft .NET Framework Configuration.
    2. Expand Runtime Security Policy, expand Machine, and then expand Code Groups.
    3. Right-click All_Code, and then click New.
    4. Select Create a new code group. Give your code group a relevant name, such as the name of the applications share. Click Next.
    5. In the Choose the condition type for this code group list, select URL.
    6. In the URL box, type the path of the share in the following format:
      file:////\\<VAR>computername</VAR>\<VAR>sharename</VAR>\*
      Note Replace <VAR>computername</VAR> with the name of the computer that is hosting the remote share. Replace <VAR>sharename</VAR> with the name of the share.
    7. Click Next. On the next page, select Use an existing permission set, and then select FullTrust.
    8. Click Next, and then click Finish.
    9. Restart Microsoft Internet Information Services (IIS) to restart the ASP.NET worker process.

    For more information, see http://support.microsoft.com/?id=320268

     

    I look forward to receiving your test results.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, January 19, 2009 1:13 AM
  • User955217749 posted

    Hello,

    thank you for your interest to help me out. I did exactly everything what you wrote, but no success. Actually this was exactly the same approach what I tried before I posted this issue.

    I am trying to imitate the same environment as my client has. :

    Windows XP (Home - no IIS)

    Microsoft Visual Web Developer 2008

    Mapped drive as "S" (on the server the physical drive letter is as "D")

    -----------------------------------------------------------------------------------------------------------

    I created new code group with the  settings you described. Myabe the problem is with the URL settings.

    In the URL section I put:   file:////\\111.111.111.111\$D\*                Is this correct? (of course I changed the IP address )

    If not, please can you write me exactly what I suppose to put there?  I don't know  what does exactly the "sharename" mean.  Is it the name of the mapped drive (in my case "S") or physical server drive letter (in my case "D").

    I map just the drive, not any folder on it.  The operating system is XP Home (it means I can not restart IIS, because there is not any). The Visual Web Developer 2008 uses "ASP.NET Development server" to test (debug) the application. As soon as I try to open the project in Visual Web Developer 2008 I get this irritating warning:



    When I try to preview the aspx page I get this error:


    I would really appreciate any further help. I am stuck on it.

    Thank you!!!

    Thursday, February 5, 2009 12:11 AM
  • User-302016627 posted

    I was facing a similar issue.

    The code files were stored on a mapped location, not on my local machine.

    I moved the entire webapp folder to my local drive and it compiled beautifully !

    Try doing this to make sure that is really the only-problem, before investing hours to fix it.

    Wednesday, March 4, 2009 8:52 AM
  • User658334913 posted

    Hi,

    Not sure if this will help but I encountered this problem while to move files from a local drive to a network share (via a mapped drive).

    I followed the instructions for editing the .Net configuration but could not get it working straight away. Eventually I got it working by using the following in the URL of the permission set


    file:////L:\test\*

    where L is my mapped drive. The thing I forgot was the wildcard (*) that is important.

    Now my only other problem is that I tried then to run a development server on the code and get a permission denied, I assume this is to do with the fact I am not in the same domain as the network share (and there is no trust), so the user the dev server runs up as is invalid.... oh well ho hum.... Tongue out


    Other thing to say is that while looking into this I couldnot find the configuration tool that allowed me to edit the .net configuration. I then stumbled across 

    http://technowise.blogspot.com/2009/03/net-framework-20-configuration-tool.html

    Installed it and I can access the tool, and thats how I made my changes.


    Wednesday, October 21, 2009 12:25 AM
  • User-1864736044 posted

    We encountered this issue and tried the common fix of running CASPOL to grant the right permissions.  However, that didn't work!

     The problem was:  WE WERE RUNNING CASPOL in the 32bit .NET directory rather than 64!

     The configuration you make at:

    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\caspol.exe

     IS DIFFERENT THAN:

     C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\caspol.exe

     

    Lesson learned:  .NET Framework configurations are not shared between 32 and 64bit installations

    Don

    Tuesday, December 8, 2009 12:54 PM
  • User1687805680 posted

    Concerning the 32-bit vs. 64-bit issue: Excellent tip!!  I'm sure it saved me at least 4-8 hours of attempted workarounds and fixes ... thank you!

     

    Dan

    Friday, July 23, 2010 1:40 AM
  • User-790486982 posted

    thanks! this solved my problem 

    Sunday, August 8, 2010 11:45 PM
  • User1840398364 posted

    After some time working on this, here are some tips that worked for me:

    The problem is that iis is trying to compile your site and it cannot execute the code in the system.web.aspnethosting… assembly (which is used during the compilation process) 

    1. Go to IIS and click on the site (or virtual directory) then press basic settings on the actions panel (right side). Change the authentication from “pass thru” to “connect as” (don’t worry, this is temporary) and enter an administrator’s username / password 
    1. Browse to the site, it will compile without problems then change the authentication back to pass-thru and browse the site again (since it no longer needs to compile, it should work).

     

    *Keep in mind that everytime you need to publish code, you will have to go through that. You can try to change the application pool identity from apppoolidentity to Network Service or another user as a permanent Solution.

    Andy

    Thursday, May 16, 2013 1:22 PM