asp.net trust level error - asp.net-mvc

I deployed an asp.net mvc application and everything worked except for my Gallery page that streams pictures using flickr api. 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.Security.Permissions.FileIOPermission, mscorlib, 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.
I went into my web.config file and changed
<location allowOverride="true">
<system.web>
<trust level="Full">
And then the site will not run at all, I get the following error
Configuration 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: This configuration section cannot be used at this path. This happens when the site administrator has locked access to this section using
location allowOverride="false"
from an inherited configuration file.
Source Error:
</customErrors>-->
<trust level="Full" />
<pages>
<controls>
The webpage is oneotacycles.com
Any thoughts? Thanks very much!!

As above, it looks like Flickr is trying to make a cache on the server, have you checked that particular folder has write permissions?
This may help, http://flickrnet.codeplex.com/Thread/View.aspx?ThreadId=24550
Inside the constructor for the Flickr
class there is a call that tries to
load the default settings from the
configuration file (i.e. web.config).
If you are running in a restricted
security environment (such as a hosted
web site with an ISP) then you might
not be allowed to put new config
sections inside a web.config file so
when it parses the file a security
exception is thrown. It will do this
anytime you create an instance of the
Flickr class.

Related

MVC web.config Error

What is the reason for this error and how to solve.
This configuration section cannot be used at this path. This happens
when the site administrator has locked access to this section using
<location allowOverride="false"> from an inherited configuration file.
An application error occurred on the server. The current custom error
settings for this application prevent the details of the application
error from being viewed remotely (for security reasons). It could,
however, be viewed by browsers running on the local server machine.
There is a hierarchy of config files that sets machine-level and then application-level restrictions over configuration sections.
If in your website you try to override one of the locked down sections up the hierarchy you will get this error.
For more information refer to these docs:
https://learn.microsoft.com/en-us/iis/get-started/planning-your-iis-architecture/the-configuration-system-in-iis-7#hierarchy

The attribute 'debug' has been locked in a higher level configuration

Im trying to upload a MVC site to a server but it just seems it wont play ball. Never had such weird errors for uploading a mvc site.
Get this message when I navigate to the web page.
The attribute 'debug' has been locked in a higher level configuration.
What the h... does that mean?
Source error:
An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
some part of the web.config that I have been messing around with:
<customErrors mode="Off">
</customErrors>
<compilation debug="false" />
It means that the debug attribute has been set at machine level and you are not allowed to change it. This is done in the global IIS configuration file that you won't have access to. In effect, a web.config just inherits from that and all your XML is just overriding or adding to those values.
Now I assume it's been locked to prevent debug="true", this means you can just remove that attribute completely, which means you can remove the entire compilation element.

There is no build provider registered for the extension '.jpg'

When I approached a jpg image www.demo.net/images/1.jpgon my web site, it gave me the error:
Server Error in '/' Application.
There is no build provider registered for the extension '.jpg'. You can register one in the <compilation><buildProviders> section in machine.config or web.config.
It is a asp.net mvc 4 site. It worked in localhost but failed on the hosted server.
So I modified it as
<compilation debug="true" targetFramework="4.5">
<buildProviders>
<remove extension=".jpg"/>
<add extension=".jpg" type="System.Web.Compilation.WebHandlerBuildProvider"/>
</buildProviders>
</compilation>
The image is not still shown and the error became wild.
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: The page must have a <%# webhandler class="MyNamespace.MyClass" ... %> directive.
Source Error:
Line 1: ÿØÿàJFIFHHÿá
Line 2: ExifMM* †Œ1˜2žÿ‡i²ˆ%VêzêAppleiPhone 3GS4.3.52012:10:27 14:22:05‚šü‚ˆ"ˆ'P0221 ‘’4’<’’ ’
Line 3: D’L’‘00’’00 0100 ¢ÿÿ¤è¤¤¤
Source File: /images/1.jpg Line: 1
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18045
There's something wrong with the handler mappings in IIS. It's trying to actually run the jpg as if it was an aspx page, but has no build provider for a file type of jpg. That's fine. It shouldn't because jpgs aren't supposed to be built. Adding a build provider for it only served to freak the hell out of the compiler. IIS should simply treat a jpg as what it is, a static file, and serve it up. You need to determine why isn't doing that.
The hosed provider reset the IIS setting, then it was resolved.

Error - The pre-application start

I am currently editing a project that was opened from a source control at my business. When trying to debug locally I get the error
Validating Web Site
: Build (web): The pre-application start initialization method Start
on type System.Web.WebPages.Deployment.PreApplicationStartCode threw
an exception with the following error message: Access to the path
'C:\Users\gary\Documents\Visual Studio 2010\WebSites\DOISAdminPortal\'
is denied..
Ive done some research and a lot of people say to delete the
add key="webpages:Enabled" value="true"
from the web.config file. It was never included in the config file so that shouldn't be the issue.
Anyone have any suggestions??
The files which were contained in the VS 2010 folder needed to be given permissions to the iis express user iis_iusrs. once this was done I was able to access all files in the directory and was able to debug the page.
Short Answer: Try turning off impersonation for local testing.
For my case, our web.config had the following line:
<identity impersonate="true" userName="DOMAIN2\admin" password="12345"/>
under the </system.web> section.
This impersonated identity functioned on the production server, but when running it on my local, the user admin from domain DOMAIN2 did not have the same privileges because my local machine was on a different domain say DOMAIN3 and did not by default give DOMAIN2\admin any rights on the system.
One way I circumvented the issue is by turning off impersonation like follows:
<identity impersonate="false" userName="DOMAIN2\admin" password="12345"/>
I suppose this defaulted my settings to use the rights from the currently logged in user.

What application trust level is need for ASP.NET MVC framework?

i am trying to deploy simple asp.net mvc frameworkd application in may shared hosting and i get erro like this:
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.Security.Permissions.ReflectionPermission, mscorlib, 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.
http://test.pakabink.lt/
In my control panel i am seting "ASP.NET 2.0 Full Trust". What i need to ask for server administrator to change?
You should be able to bin deploy and run the MVC framework in medium trust. There is a possibility that there is some other permission that the hosting company has taken away but it should work. Are you testing with the default MVC project? If you are using other components (Structure Map, for example), that may be causing the error.
Check out Bin Deploying ASP.NET MVC from Phil Haack about deploying and the required trust level.
Medium trust does not allow certain Reflection operations. I guess some part of your code does or calls other part(s) of code.
Web deploy copies some System.Web dlls to bin folder, for example System.web.MVC but not all. It is kind of lot of debugging to determine which ones are missing, like the previous comment said about reflection methods.

Resources