UnauthorizedAccessException - The image location is not under specified directory - c#

I am copying a web site, written in asp .NET, from a windows server 2003 machine to a windows server 2012 with IIS 8.5.
The web site is working great on the old machine, but no charts are displayed in any of my webpages on the new machine.
I get a strange error:
General Information
--------------------------------
MachineName: AYEVENS12MAVTST
TimeStamp: 10/08/2014 11:38:18
WindowsIdentity: NT AUTHORITY\SYSTEM
Exception Information
---------------------------------------
Exception Type: System.UnauthorizedAccessException
Message: The image location is not under specified directory.
Data: System.Collections.ListDictionaryInternal
TargetSite: Void ValidateUri(System.String)
HelpLink: NULL
Source: System.Web.DataVisualization
HResult: -2147024891
StackTrace Information
---------------------------------------
at System.Web.UI.DataVisualization.Charting.ChartHttpHandlerSettings.ValidateUri(String key)
at System.Web.UI.DataVisualization.Charting.DefaultImageHandler.System.Web.UI.DataVisualization.Charting.IChartStorageHandler.Load(String key)
at System.Web.UI.DataVisualization.Charting.ChartHttpHandler.ProcessSavedChartImage(HttpContext context)
at System.Web.UI.DataVisualization.Charting.ChartHttpHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
This is weird since I see the path of the picture is correct and I can open the picture with no problem.
I thought it's a permission problem but I gave full control of the containing folder to IIS_USRS and to WindowsIdentity: NT AUTHORITY\SYSTEM and the same error keeps popping up.
What troubles me is the message "The image location is not under specified directory." since the image is where it's supposed to be.
Any help would be appreciated.

Have you tried to impersonate a specific authorized windows account using the web.config file ?
<configuration>
<system.web>
<identity impersonate="true" userName="user name" password=" user password" />
</system.web>
</configuration>

Well I solved it by (accidently) removing the line
<add key="ChartImageHandler" value="storage=file;privateImages=false;timeout=600;dir=c://TempImageFiles;deleteAfterServicing=false;" />
from the webconfig, I have no idea why this works.

Related

Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) on local pc

i am using fully asp.net configured site i take it from this link
http://www.codeproject.com/Articles/37660/Fully-configured-ASP-NET-Membership-Website-Templa
as a template to my project, all what i did is changing the conection string on the web.config file to point to my database
<connectionStrings>
<add name="AspNetMembershipTemplateConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Members.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
and i run the project locally , but the problem that when i debug it it show this error
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
i google it , and i found that happen because of the privileges but i am using my user and its administrator account , how can you help me with this problem?
You are probably having the code in a folder that the IIS account can't access. Move to the wwwroot/Inetpub folder or grant appropriate privileges to the IIS service account for the folder where the code is in.
Edit
I was just reading the exception in the image. When you read the exception thoroughly you will even see that it suggests to edit the privileges.
i use the project in my local pc without needing to use IIS , so i solve this by close VS2012 and reopen it as administrator .. and its work fine

Event message: An unhandled access exception has occurred (IIS 7.5, cannot load website)

I deployed the Nuget source code to my company's web server, but when navigate to the URL, I get the following error (pulled from Event Viewer on the server):
Event code: 4011
Event message: An unhandled access exception has occurred.
Event time: 11/6/2013 9:02:54 AM
Event time (UTC): 11/6/2013 3:02:54 PM
Event ID: 2f5d6f7e594e47259b6dc050f82fc57d
Event sequence: 2
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/2/ROOT/Nuget-3-130282237713215393
Trust level: Full
Application Virtual Path: /Nuget
Application Path: E:\omitted\omitted\Nuget\
Machine name: SERVERNAME
Process information:
Process ID: 1420
Process name: w3wp.exe
Account name: DOMAIN\serviceAccount
Request information:
Request URL: http://subdomain.domain.net/nuget
Request path: /nuget
User host address: ***.**.***.**
User:
Is authenticated: False
Authentication Type:
Thread account name: DOMAIN\serviceAccount
Custom event details:
This will run just fine on my local machine, but not on the web server. Does anyone have any ideas as to what the problem might be? All I did was take the Nuget source code, modify the database details in the web.config to point to my database, and deploy it to the web server.
The local users group needed modify permissions to get past this error. Resolved.
I would just like to clarify for anyone else who comes to this question. The permissions need to be changed on the folder where the website resides in windows explorer.
I had this exact error - the only solution that worked was setting the app pool's Enable 32-bit Applications advanced setting to True.
Update: As I continue to have issues with a particular solution, I've found that clearing the C:\WINDOWS\Microsoft.NET\Framework\v4.xxx.xx\Temporary ASP.NET Files\
resolves the issue in most cases.
This error can also occur if for some reason access to a single file is unexpectedly denied. In my case the website was working fine but after a while access to a temporary entity framework edmx cache file was denied. Deleting this file solved the problem.
Setting CustomErrors in Web.Config to Off gave me the details about the error. These details were not present in the event log viewer.

Configuration error in ASP.NET website

I recently started getting this error:
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: An error occurred loading a configuration file: Failed to start monitoring changes to 'H:\2013 T1\SIT302 Project\Deliverables\Website' because the network BIOS command limit has been reached. For more information on this error, please refer to Microsoft knowledge base article 810886. Hosting on a UNC share is not supported for the Windows XP Platform.
Source Error: [No relevant source lines]
Source File: refers back to the web config file Line: 0
I have no idea why this is happening.
The following is contents of my web config file.
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
</configuration>
It seems H:\2013 T1\SIT302 Project\Deliverables\Website is a network path not a local path and there is a network problem between the IIS Server and the file server containing the website files. Check the network connectivity.
Users of IIS and ASP.NET often receive this error message when running a website from a network share or NAS device. Check this LINK for more information and the solution.
I made a very detailed answer to this problem here: https://stackoverflow.com/a/20710473/705198
That answer is an accumulation of all the technet, msdn, and blog reference material I could find on the subject, and what we ended up having to do to fix the problem. Disabling Jumbo Frames (HP Server NIC problems causing another error) and SMB2+ combined with the registry edits were what ended up saving us with our high traffic IIS sites. The registry edits alone only made it so the network bios limit errors would not show up as fast under normal load.

Writing to Network Folders with ASP.net C#

I'm having trouble accessing a network share using ASP.net C#.
I've used the identity in web.config
<identity impersonate="true" userName="username" password="password" />
And changed the machine.config file. I've also enabled impersonation in IIS.
I try to use this code:
System.IO.Directory.CreateDirectory("\\\\networklocation\\test");
And I get the following error:
Parser Error Message: Could not create Windows user token from the credentials specified in the config file. Error from the operating system 'Logon failure: unknown user name or bad password.
The network share location has access to all users (everyone account).
Any ideas whats going wrong here?
Are you specifying the correct domain for the user?
<identity impersonate="true"
userName="domain\user"
password="password" />
why do you use impersonation if everyone account is active ?
remove the impersonation Section

That assembly does not allow partially trusted callers although the zone is fully trusted

Since yesterday, I receive a security exception when I want to run a unit-test from within VS.NET 2008.
The error goes like this:
SecurityException: that assembly does not allow partially trusted callers
...
The assembly that failed was : file:///S:/MyProject/MyAssembly.dll
The S: drive is a mapped drive which points to a physical location on my disk.
What I find very strange, is that this used to work for months previously. I mean, I did this all the time.
In order to get this to work, I 've created a new security zone with the caspol utility in order to give this S: network share drive FullTrust.
In other words, when I run
caspol -m -lg
I see this (I removed the other zones for the sake of brevity):
1.2. Zone - Intranet: LocalIntranet
1.2.1. All code: Same site Web
1.2.2. All code: Same directory FileIO - 'Read, PathDiscovery'
1.2.3. Url - file://R:/*: FullTrust
1.2.4. Url - file://S:/*: FullTrust
1.2.5. Url - file:///S:/*: FullTrust
I've added the 1.2.5 zone just recently because the error that was given, mentionned file:///s:/....
Any ideas ?
Could it be that this has something to do with the installation of VS.NET 2010 or the .NET Framework version 4.0 ?
Try adding
<configuration>
<system.web>
<trust level="Full" />
</system.web>
</configuration>
to your web.config.

Categories

Resources