Caspol: .Net 2.0 app failing on win 2008 when hosted on UNC path
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=2.0.0.0, 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
Till then
Comments
Anonymous
December 17, 2009
Thanks for posting this! We were facing this exact problem.Anonymous
December 17, 2009
Hi Mike, I'm glad it helpped you. Thanks JAsAnonymous
April 29, 2010
Helped to sole my problem, thank you)Anonymous
November 15, 2010
Hi, Thanks for this article, we had the same issue and after a couple of hours I found this site and 64bit, suddenly the light bulb came on and all was well with our IIS :-) Thanks.Anonymous
May 12, 2011
Thanks again, this helped me solve the same problem.Anonymous
February 08, 2014
Thank you for this! Saved my bacon during my migrations this weekend.