Getting Exception / The Application Attempted To Perform An Operation Not Allowed By The Security Policy
Nov 10, 2010
i have an dll file which is data access layer of my application.
i am getting this exception while accessing databse
Description:
The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission 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.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
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.Local its run fine. when i place in iis. it throw this exception.
I have a function that finds a files MIME type for download purposes. I use this DllImport:
Code: [DllImport("urlmon.dll", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = false)] static extern int FindMimeFromData(IntPtr pBC, [MarshalAs(UnmanagedType.LPWStr)] string pwzUrl, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I1, SizeParamIndex = 3)] byte[] pBuffer, int cbSize, [MarshalAs(UnmanagedType.LPWStr)] string pwzMimeProposed, int dwMimeFlags, out IntPtr ppwzMimeOut, int dwReserved);
I use this function:
Code:
#region GetMimeFromFile(string) public static string GetMimeFromFile(string file) { IntPtr mimeout; if (!File.Exists(file)) { throw new FileNotFoundException(file + " not found."); } //if int maxContent = (int)new FileInfo(file).Length; if (maxContent > 4096) { maxContent = 4096; } //if byte[] buff = new byte[maxContent]; using (FileStream fs = new FileStream(file, FileMode.Open)) { fs.Read(buff, 0, maxContent); } //using int result = FindMimeFromData(IntPtr.Zero, file, buff, maxContent, null, 0, out mimeout, 0); string mime = Marshal.PtrToStringUni(mimeout); Marshal.FreeCoTaskMem(mimeout); return mime; } #endregion
Locally, it runs fine. However, when I put it on a GoDaddy server, I get the error:
"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. "
My stracktrace points to line 256, which is the ending french bracket of my GetMimiFromFile function.
I use dynamic currency symbol(Doller,£,etc.,) for that the web config is updated in locally but in site I can not modifiy the web config file and 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: Requested registry access is not allowed.
I'm calling Another url from my web aspx page. I'm writing
[code]....
But I'm getting error
A socket operation was attempted to an unreachable host 208.101.14.59:80
I tried the same url by pasting it on address bar and works fine. When I call my vendor they r saying that there is no any problem from their side. Someone has suggested me that there may be some settings in web.config.
I write code for sending mail. Its working fine in local  at Execution time. After i Hosted into server. it shows the Error.
A socket operation was attempted to an unreachable host [IP]:587
code:
Dim mail As New MailMessage mail.To.Add("xxx@abc.com") mail.From = New MailAddress("yyy@gmail.com") mail.Subject = "Subject" mail.IsBodyHtml = True mail.Priority = MailPriority.High
I'm a asp.net newbie trying to figure out how to do the following. I have a datatable. I want to extract the first row and perform a certain operation and a different operation on the remaining rows. How would I loop through the datatable to do this?
I have a website in asp.net 2.0 which write some thing on a file. But at the same time if another user hit that site it does not work till the first one operation on the file completed after that second one can do operation with the files.
I need to dispay confirm box on server Side.. senario is like Im Trying To upload Image During Upload Im Checking some properties like Image type,image size, etc.. While Uploading i want to check properties like
I am getting an exception that child actions are not allowed to perform redirect actions. Although I can understand that this might is true in most situations I do believe that the framework might allow this to pass when a Child Action is calling another child action like in this example:
I have this code in my CountryController (I compacted it a bit but the main concept remains that I have a controller with Child Actions only):
[Code]....
This exception is being thrown:
Server Error in '/' Application.
Child actions are not allowed to perform redirect actions. Description:An unhandled exception occurred during the execution of the current web request. Review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Child actions are not allowed to perform redirect actions.
I am working on a government site and am having some problems with my local security policy interferring with my web application. There is a setting called "System cryptography: Use FIPS 140 compliant cryptographic algorithms, including encryption, hashing and signing algorithms" which is enabled on my server.
Since that has been enabled, most of my aspx pages are returning the error "This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms." These pages aren't accessing any cryptographic methods. They do communicate with another database server, but that's it.
My problem is similar to the one described here. However, I don't have the option of disabling this FIPS security setting.
I am using .NET 4.0, IIS 7.0, and Windows Server 2008 R2, if that matters. Has anyone encountered this problem before?
Update
Unfortunately, correcting the machine key element to use a FIPS compliant algorithm did not completely solve my problem. I am still getting the error on alot of my pages.
I found two hotfixes which may be related. I will try to install these and see what happens.
SQL Server Reporting Services R2 hotfix ScriptManager Control hotfix
I'm working on a SharePoint solution which makes use of a third party dll (Telerik for Asp.Net Ajax - Telerik.Web.UI.dll) for rich experience. Since Telerik dll is a common assembly i have to deploy it to the bin folder of the webapplication instead of GAC. So here comes the problem.
WSPBuilder automatically deploys the dll to gac if the dll presents in the GAC folder. To deploy the telerik dll in bin i created the folder 80in and copied the dll there. I tried to build the wsp again and then went through the manifest.xml created. Great. The deployment target for the dll changed to WebApplication and wspbuilder was smart to create the cas policy itself.
But Wspbuilder was not smart enough to put the four part name of SharePointPermission IPermission class. But i learnt that CAS actually requires the four part name. So i decided to make use of the -CustomCAS command line option of wspbuilder.exe to pass my custom cas policy file.
when i run my application i got this error like...
Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Security.Policy.PolicyException: Required permissions cannot be acquired.
If you enable the "Use FIPS compliant algorithms for encryption, hashing, and signing" security policy option in Windows, attempting to use many of the cryptographic classes in the .NET Framework will result in an InvalidOperationException. By default, ASP.NET uses AES to encrypt the ViewState blob, so it fails. You can work around this by adding a key like this to web.config:
And that covers you for basic ASP.NET use. My problem is this: I have a large, complex ASP.NET web applications that makes heavy use of ScriptManagers (the foundation of ASP.NET AJAX) and needs to be deployed by a government customer who must enable this FIPS policy setting. Any ASP.NET page with a ScriptManager on it throws this exception:
[InvalidOperationException: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms.] System.Security.Cryptography.SHA1Managed..ctor() +3607454 System.Security.Policy.Hash.get_SHA1() +45 System.Web.Handlers.ScriptResourceHandler.GetAssemblyInfoInternal(Assembly assembly) +85 System.Web.Handlers.ScriptResourceHandler.GetAssemblyInfo(Assembly assembly) +99 System.Web.Handlers.RuntimeScriptResourceHandler.GetScriptResourceUrlImpl(List`1 assemblyResourceLists, Boolean zip, Boolean notifyScriptLoaded) +525 System.Web.Handlers.RuntimeScriptResourceHandler.System.Web.Handlers.IScriptResourceHandler.GetScriptResourceUrl(List`1 assemblyResourceLists, Boolean zip, Boolean notifyScriptLoaded) +910 System.Web.Handlers.RuntimeScriptResourceHandler.System.Web.Handlers.IScriptResourceHandler.GetScriptResourceUrl(Assembly assembly, String resourceName, CultureInfo culture, Boolean zip, Boolean notifyScriptLoaded) +193 System.Web.UI.ScriptReference.GetUrlFromName(ScriptManager scriptManager, IControl scriptManagerControl, Boolean zip) +306 System.Web.UI.ScriptManager.RegisterUniqueScripts(List`1 uniqueScripts) +169 System.Web.UI.ScriptManager.RegisterScripts() +407 System.Web.UI.ScriptManager.OnPagePreRenderComplete(Object sender, EventArgs e) +200 System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +11041982 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3672
Even adding the <enforceFIPSPolicy enabled="false"/> element to web.config does not resolve the exception.
Is there any way to configure ASP.NET such that ScriptManager can be used with the Windows FIPS security policy?
I have a web page that uses System.Net.HttpWebRequest class that used to work perfectly fine for 2 years, and then all of a sudden I started to get the following error.[WebException: The operation has timed out] System.Net.HttpWebRequest.GetResponse() +5314029Also, I tried the application on my local machine and it works fine, do you think it is a setting change on my hosting server?I already tried the response.close and it didn't work.
I'm having hard time to figure out whats going on with my IIS.My application was running in IIS very well untill I used Visual studio Copy website to update the files in the wwwroot.All of a sudden I got this error.My application works fine from the file system.I tried deleting my application from IIS and uninstalled from control panel and ran the newly built msi/exe but I never got my application back what so ever.This is web.config for reference.I've also tried <trust level="Full"> element but this didn't help.I remember the whole problem started when I was trying to debug the functionality to upload and download files in ASP.Net.
I get the Subqueries are not allowed in this context. Only scalar expressions are allowed - i am going to run into this quite alot so I figuredI'd better see what the right way is!
These types of exceptions always irritate me because they are almost impossible to reproduce consistently and have almost no documentation other than the cryptic error itself to have any idea on how to fix the problem. So I have a Windows Service that makes a call to a .asmx web service over https on a polled interval every 20 minutes. Once in a great while the following exception message is returned:
Message: The underlying connection was closed: An unexpected error occurred on a receive.
Inner Message: System.IO.IOException: The decryption operation failed, see inner exception. ---> System.ComponentModel.Win32Exception:
The specified data could not be decrypted --- End of inner exception stack trace --- at System.Net.Security._SslStream.ProcessReadErrorCode(SecurityStatus errorCode, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest, Byte[] extraBuffer) at System.Net.Security._SslStream.ProcessFrameBody(Int32 readBytes, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security._SslStream.StartFrameBody(Int32 readBytes, Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest) at System.Net.TlsStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
So from reading the above message there was an error on receive and the data could not be decrypted. The does not occur consistently, so I don't have a good way of reproducing it. I also lack at low level messaging knowledge and I feel that this is the answer behind this exception; i.e. dropped packets and an incomplete message not appearing to be the same message as sent from the service or something. Any .asmx gurus out there that can give insight and possibly prevention suggestions for the above issue?
I ahev seen many discussion related to this , but I could not find proper answer , I have live web site set up on IIS 6, and set virtual path MYSite and then phisical path to the web.config file on actual location.
I have copy this site to another server for the purpose of further development, so I need to run production site exactly same as live site , i can do edit in production and update pages to live.
Once I have copied the site give this error virtual path '/includes/menu.htm' maps to another application, which is not allowed
i have master page include menu as html files <!--#include file="../includes/topmenu.htm"-->
I have open site in IIS 7 and add virtual directory and gave a name (not same as live) and choose physical path to the root folder of the site. In IIS 7 I cannot give web.config file for the path, it should be folder. and I have change identity in apppool to Network Service and gave readaccess permission to folder.
Server Error in '/' Application. Attempted to read or write protected memory. This is often an indication that other memory is corrupt.Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
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.