Member Avatar for Member #88336

Keywords:
ASP.NET app with VS2005 running on Win2003 with IIS6, and SQL2000 on a WinXP Box

I've betting the following for days... it's driving me insane:

Server Error in '/' 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=,
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.

The referenced token can be found here:
<DbSource
ConnectionRef="strMRConn_Test_System (Web.config)" [...]
ScalarCallRetval="System.Object, mscorlib, Version=,
Culture=neutral, PublicKeyToken=b77a5c561934e089">
This is in my XSD (DataSet) file.

I believe this is a compile error (not an RTE), as the default page has no connection to SQL and it's plain HTML. Yet I can buil successfully! Running (w/ or w/out debugging won't work).

The ASPNET account of the IIS6 server has full permission on the site folders (under wwwroot).

PLEASE help,
AnalogKid17

Dani AI

Generated

This exception means the runtime refused an operation because the application does not have the required AspNetHostingPermission under the current code-access trust level. File-system/NTFS rights (what you changed for the ASPNET account) are different from Code Access Security (CAS); giving the ASPNET user full NTFS access will not change CAS behavior.

Quick diagnostic (safe, reversible)

  • Add a temporary trust element to the app's web.config, recycle the app pool, and retest. If the error disappears you’ve confirmed it’s a trust/CAS issue:
<configuration>
  <system.web>
    <trust level="Full" />
  </system.web>
</configuration>

If that fixes it, remove the setting and use one of the safer long‑term approaches below.

Common fixes and next steps

  • If you control the server: adjust the machine/web trust policy or grant the specific assembly/folder FullTrust via CAS policy.
  • If you’re on a hosted server with Medium/Partial trust: contact the host or move the code that requires full trust into a separate full‑trust service (or a Windows service/GAC assembly).
  • Ensure assemblies execute from a local drive (not a UNC share) and aren’t blocked by Windows (right‑click → Properties → Unblock if present). Rebuild on the server to remove “downloaded” evidence.
  • As a last resort, consider signing and installing trusted assemblies into the GAC or rewriting the component so it doesn’t require AspNetHostingPermission.

Notes on the thread

  • ’s advice (moving the executable to the user’s machine) can work when the problem is network-origin/zone trust, but it’s a workaround rather than a server-side fix.
  • : try the quick diagnostic above first; if Full trust fixes it, narrow the offending component and choose the least-privilege remediation that your hosting situation allows.

Caution: granting Full trust opens security exposure on shared hosts — prefer targeted CAS policy or refactoring where possible.

Did you ever resolve this issue? If so, how?

This exception is occurs when user run an application that attempts to access their login information from a different machine. My method for getting around this was simple: move the executable to the user's machine.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.