使用托管服务提供商托管应用程序(共享托管)

hosting an application with the hosting provider (shared hosting)

我有一个应用程序在我的本地计算机上运行良好,但在主机 space 中上传时出现错误。我打电话给我的托管服务提供商的技术支持,他们的技术不足以知道问题出在哪里,他们只告诉我他们不允许完全信任级别。

下面是访问我的 URL:

时出现的错误

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.Security.Permissions.ReflectionPermission, mscorlib, Version=4.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.

Stack Trace:

[SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.] System.Delegate.DelegateConstruct(Object target, IntPtr slot) +0 Owin.Loader.DefaultLoader..ctor(Func'3 next, Func'2 activator, IEnumerable'1 referencedAssemblies) +69 Microsoft.Owin.Host.SystemWeb.OwinBuilder.GetAppStartup() +65 Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +28 System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +86 Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +106 System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +418 System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

版本信息:Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34280

Screenshot of the error

谁能帮我解决这个问题?

您正在调用 Microsoft.Owin DLL,这些 DLL 需要完全信任,在中等信任下它们不会 运行。如果您的主机不支持完全信任,您需要找到 Microsoft.Owin 的替代方案 运行 中等信任,或者将托管提供商切换到支持完全信任的主机。

查看此 post Is trying to develop for Medium Trust a lost cause? 了解更多详情。