Helping one of mate in our team with issue where Asp.net application was failing with System.Security when contents were pointing to UNC path.We were getting following error in the browse:
Parser Error Message: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=18.104.22.168, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. (\\abc02\myapp\web.config line 84)
This application was hosted on windows 2008 - IIS 7 server.
First thing came into my mind is to see whether we've set FullTrust according to KB 320268.We were using caspol.exe to set permissions as we were missing Microsoft .NET Framework 2.0 Configuration tool (it gets installed with SDK) :-)
Running following command in CMD
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727> caspol.exe -m -ag 1 -url "file:////\\computername\sharename\*" FullTrust -exclusive on
Application in question was still failing with same error. As a general troublehsooting step thought to try with new share folder and with simple test.aspx in it. Then added Fulltrust permission for that path and it worked. Now that made me to point finger toward the application compatibility.
Next steps was looking into procmon logs and it seem like .Net was trying to read config file from framework64 folder.That raise eyebrow and apparently application was hosted on win2008 x64 server and was running in native mode.
It turns out that .NET stores its security configuration separately for x64 and x32. Thatz it. we have to run the command again from the Framework64 instead of Framework folder
C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727> caspol.exe -m -ag 1 -url "file:////\\computername\sharename\*" FullTrust -exclusive on