Trying to get an ASP application deployed; it worked for a while but then started coming up with errors whenever the page is accessed:
Server Error in '/AppNameHere' 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.
An IISreset didn't change anything, but rebooting the entire system got it to work for a few hours before the problem came back. The .config for the application is set to full trust.
What could be causing this, and how can it be fixed? (Or, if more information is needed, where do I go looking to find it)
Found the following on Jason Gaylord's blog:
System.Web.AspNetHostingPermission when Accessing Network or Intranet Projects using Visual Studio 2005
I rebuilt one of my development machines recently and attempted to access a project that I had out on a network share. I continually received project messages about the project not being trusted. I remembered that I had to change something but couldn't remember what it was until I found an old note I left in Outlook.
The message I would receive in Visual Studio 2005 was: ASP.NET runtime error: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
To resolve this issue, you must change your development machine .net security configuration since you are accessing items across the network. In the event that you need this ability at runtime, you must change the trust level in your config file to full. However, since this is only in development,
I can change my local PC's security
by going to Start > Control Panel >
Administrative Tools > Microsoft
.NET Framework 2.0 Configuration.
After it fully loads (sometimes
takes a bit), fully expand My
Computer in the navigation tree and
click Runtime Security Policy.
In the right hand pane, choose
Adjust Zone Security. Leave the
default option (Make changes to this
computer) and hit next.
Choose Local Intranet and change the
trust level to Full Trust. Then
choose next and then finish.
Restart Visual Studio 2005 and you
should be all set.
This worked for me ... so hopefully this will work for you!
Related
I've developed a site using the Umbraco 7 CMS system, all works great and I've been able to copy and deploy this to numerous other machines and severs without any issues.
However now that we have tried deploying this to the live server, we are unable to login to the backend Umbraco section. The error is as follows:
Received an error from the server
Server call failed for getting current user
Could not load file or assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Access is denied.
Exception Details:
System.IO.FileLoadException: Could not load file or assembly 'Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Access is denied.
The only different here is that the live server is administered by a Plesk control panel. So the actual site within IIS were created using this. However we have full Remote Desktop access and have set all the required "full control" permissions. And have checked that we have the correct .NET versions installed. But with no luck.
Has anyone experienced this or have a fix, I've searched Google and can't find anything that works.
Thanks
I haven't run into this myself, but it sounds like the server where you are trying to run your live site does not have the Windows Identity Foundation installed. I'd try installing that on your production server. Alternatively, you could find Microsoft.IdentityModel.dll reference in your solution right click it, open its properties and set Copy Local to true. That will cause the referenced dll to actually be dumped into the bin on compile. If you then deploy those dlls from the bin, your live site should be able to find them. You might have to go through that a couple of times until you find all of the Windows Identity Foundation dlls you need to get to.
It sounds like WIF has been integrated into the .NET 4.5 framework. It is depreciated and you shouldn't use it unless you are developing with .NET 3.5 or 4. I wouldn't expect you to be having this problem on .NET 4.5. What version of .NET framework are you using?
See What is Windows Identity Foundation for more info on WIF
Was any of that helpful?
I am receiving the following error message:
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: System.Security.Permissions.SecurityPermission
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: System.Security.Permissions.SecurityPermission]
MySql.Data.MySqlClient.MySqlClientFactory..cctor() +23
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272
MySQL: mysql-connector-net-6.7.4
The problem only occurs if run from the shared web hosting environment. The site works great locally. I know the version of the .Net connector that my shared hosting environment uses, as that was another issue that I resolved and I was in communication with the hosting provider.
The error is interesting. I can go to the default page, no issues, the very first time. I then go to bring up a popup dialog, which throws another error message box.
Exception has been thrown by the target of an invocation.
The above is everything, except for the okay button.
I can bring up the first popup, a sign in dialog, which comes up. That dialog does not invoke MySQL. I bring up the second dialog, a registration dialog, which then throws the "Exception has been thrown..." message box. After that, I cannot go back into the sign-in dialog, as I get the "Exception has..." message box. If I press F5 to refresh the browser (IE or Chrome), I get the error from above. The above error indicates MySQL and some permissions.
I am suspecting that the "Exception has been thrown..." error is the result of the same MySQL, just the page has memory. Closing the browser window and launching the browser window again does not help, although on Chrome that works, just the browser window there really has to close down all the way.
I am in a shared hosting environment, so I have access to basically nothing, so I do not have access to any logs, at least that I can think of.
One final thought that may or may not be relevant. Yesterday and previous days my development work was done on a system with Windows 7 Professional and Visual Studio 2012 Professional (all latest service packs and updates), whereas today I am working at a different computer of mine, which is a system with Windows 8 Professional and Visual Studio 2012 Ultimate (all latest service packs and updates on the OS and VS). I was reading some other posts on unrelated issues that people with VS2012 Ultimate had issues, so I am not sure that has anything to do with it, but that is something that changed from yesterday to today.
Yes, I deleted everything off of the server and uploaded everything anew. I did a clean solution first, built the release, and then published. I still received the same error.
Any thoughts?
By default most hosts use "Medium" trust level. You can change your web.config as below to get full trust:
<configuration>
<system.web>
<trust level="Full" />
</system.web>
</configuration>
Using .NET 4.0, I have a small ASP.NET app that utilized the ReportViewer object, I have created a web page that takes some user input and generates a report that is displayed using the ReportViewer control with ProcessingMode set to local.
Naturally, it works perfectly when run via VS 2010 in debugging mode and if I publish it to IIS running on my local machine. However, when I push it to production, I get the following error when actually trying to run the report
For the image impaired:
Failed to load expression host assembly. Details: Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Access is denied.
I have verified that the assembly (as well as the other reportviewer dependencies) is in the GAC. There don't seem to be any errors in the event log on the server.
Any ideas what the permission problem might be?
What authentication are you using in IIS? (e.g. windows, anonymous, ASP.NET impersonation)
As it happens, the production environment I was deploying to is a web farm and the virtual directories point to a location on a network drive. When I tried deploying to a non farm server, with a virtual directory located on the server itself, this worked. The permissions are identical in the two environments, so I can only assume that something about this control didn't like being located on a different box than IIS and ASP.NET.
I'm not sure if this is actually an "answer", so apologies in advance if I've handled this wrong from a stackover perspective.
I have an ASP.NET application, using LINQ to connec to a SQL Server 2008 R2 databse.
My connection string:
Data Source=[SqlServerIp];Initial Catalog=[databaseName]User Id=newLogin;Password=newPassword;
When I deploy the application on my local IIS (which is not the same machine as database server) it works fine, but when I deploy application on other IIS (the same machine as SQL Server) it throws an exception:
System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Anyone knows how to fix it? Maybe it is due to some bad configuration of IIS?
I would get this error when trying to run a Web Service in debug mode. I found that it was because code was on a network drive (in my case my documents was on the home drive).
I would suggest checking that the code in not a network drive.
I had faced the same problem, and I resolved this way:
Changing the app pool identity that my application uses in IIS to pre-built account NetworkService.
The default identity is ApplicationPoolIdentity, and looks like it doesn't have enough privileges to access network resources.
The security context under which your ASP.net application is running does not have permissions to load that sql client assembly. The out of the box context, ASPNET, does, so there's problem been some custom configuration that has broken it...it's difficult to say what without being able to look at the box.
But the bottom line is that the security context of the application doesn't have perms to that assembly. The following steps should get you working:
Write a page that outputs the security context of the application:
Response.Write(System.Security.Principal.Current().WindowsIdentity.Name);
Add the user named on that page to the administrators group. This should allow the assembly to load.
Reduce the permissions of the specified user to a minimum downward from administrator.
I've got an ASP.NET WebForms app that I've written, which uses the ASP.NET AJAX Toolkit. I've put the MultiView control onto the web form, and it worked fine, when I had it under Vista. Well, I had to replace my machine (HD failed) and I went to Windows 7 Ultimate. I tried copying the ASP.NET app from the system (before it finally failed for good) and put it onto the Windows 7 machine. I can bring up the app fine, go to all pages, but the one with these controls on it. When I do I get the following error:
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.
What's going on? How do I fix it?
I was able to fix this in my dev environment (local machine) by changing an advanced setting on my Default Application Pool. The section titled 'Process Model' has a setting 'Load User Profile'. When I changed this to 'True' the issue stopped happening.