---
title: "UserControl och säkerhet?"
type: "forum-thread"
url: "https://www.webforum.nu/amne/dotnet/167704-usercontrol-och-säkerhet"
topic: ".NET"
topic_url: "https://www.webforum.nu/amne/dotnet"
author: "CatZ"
published: "2008-01-01T11:12:26.000Z"
updated: "2008-01-02T02:23:56.000Z"
replies: 2
views: 629
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/dotnet/167704-usercontrol-och-säkerhet"
---

# UserControl och säkerhet?

## #1 — CatZ, 2008-01-01T11:12Z

Jag begriper ingenting. Jag har en UserControl som heter LoginControl och ligger i mappen Controls. Denna vill jag sedan inkludera i mina masterpages så at anänvdaren smidigt ska kunna logga in.

Namespacet för LoginControl blir därför 

```
namespace UI.Controls.LoginControl
```

 och klassen blir 

```
public partial class LoginControl : System.Web.UI.UserControl
```

 

Lokalt fungerar det i både IIS7 och via dev.exe's inbyggda men varför i hela friden fungerar det inte på webbhotellet?

Får meddelandet 

> **Binero skrev:**
>
> 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: That assembly does not allow partially trusted callers.
> 
> Source Error: 
> 
> 
> \[No relevant source lines\]
>  
> 
> Source File: c:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\Temporary ASP.NET Files\\root\\1e43024f\\7ba1a24e\\App_Web_uskq3nru.1.cs    Line: 0 
> 
> Stack Trace: 
> 
> 
> \[SecurityException: That assembly does not allow partially trusted callers.\]
>    ASP.news_aspx..ctor() in c:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\Temporary ASP.NET Files\\root\\1e43024f\\7ba1a24e\\App_Web_uskq3nru.1.cs:0
>    \__ASP.FastObjectFactory_app_web_uskq3nru.Create_ASP_news_aspx() in c:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\Temporary ASP.NET Files\\root\\1e43024f\\7ba1a24e\\App_Web_uskq3nru.2.cs:0
>    System.Web.Compilation.BuildResultCompiledType.CreateInstance() +49
>    System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +115
>    System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +31
>    System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +40
>    System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +139
>    System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +128
>    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +161

Permalänk: https://www.webforum.nu/p/167704

## #2 — Josef, 2008-01-01T16:34Z

Minns inte om man har någon AssemblyInfo.cs-fil i ASP.NET-projekt. Men om du har det kan du prova att sätta den här flaggan i den:
\[assembly: System.Security.AllowPartiallyTrustedCallers()\]

Permalänk: https://www.webforum.nu/p/2067293

## #3 — CatZ, 2008-01-02T02:23Z

Det stämmer bra, det var mitt AccessProvider projekt som behövde det!

Permalänk: https://www.webforum.nu/p/2067381

---

Tråden på webben: https://www.webforum.nu/amne/dotnet/167704-usercontrol-och-säkerhet
