Partager via


"System.Security.SecurityException: Security error" error message when the virtual directory points to a remote share in ASP.NET

This issue is documented in https://support.microsoft.com/?id=320268. I recently worked on issue where the customer was using a virtual directory in IIS 6.0 that points to a remote share to host a Microsoft ASP.NET-based application. The remote share was on a 3rd party NAS device (NetApp Filer). The actual error message was

Server Error in '/XYZ' Application.


Security Exception

Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

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

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

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

   System.Reflection.Assembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) +0

   System.Reflection.Assembly.GetType(String name, Boolean throwOnError) +12

   System.Web.Compilation.BuildResultCompiledType.GetPreservedAttributes(PreservationFileReader pfr) +73

   System.Web.Compilation.PreservationFileReader.ReadFileInternal(VirtualPath virtualPath, String preservationFile, Int64 hashCode) +630

   System.Web.Compilation.PreservationFileReader.ReadBuildResultFromFile(VirtualPath virtualPath, String preservationFile, Int64 hashCode) +79

   System.Web.Compilation.DiskBuildResultCache.GetBuildResult(String cacheKey, VirtualPath virtualPath, Int64 hashCode) +71

   System.Web.Compilation.BuildManager.GetBuildResultFromCacheInternal(String cacheKey, Boolean keyFromVPP, VirtualPath virtualPath, Int64 hashCode) +166

   System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean isPrecompiledApp) +65

   System.Web.Compilation.BuildManager.CompileGlobalAsax() +51

   System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +462

Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832

Even after following the resolution section in https://support.microsoft.com/?id=320268 we were still getting the same error. To isolate the issue I had the customer create another network share on a Windows Server and then apply KB 320268. We were sucessfully able to browse to the ASP.NET application. Nice trick right? :)

At this point it's very easy to convince the customer that the issue is with a 3rd party product and redirect them to the 3rd party for further assitance before closing out the case. I got the feeling that the customer could sense that this was coming but I wasn't ready to give up yet.

After a lot more digging...we found that the NetApp Filer was having two hostnames but a single IP adress.........

 Eureka!

 Eureka!

The next logical thing to do??

In step 6 while adding a new code group type in the IP adress of the NAS Device instead of the hostname.

Replace file:////\\computername\sharename\* with file:////\\<IPAdress>\sharename\*

Until next time...Cheers!

Comments

  • Anonymous
    September 07, 2007
    THANK YOU!!!!! I'm working on an enterprise deployment of DNN and want to store the website on a network share and this is what has been holding me up. Finally I can move on to the next thing that will hold me up. :)