webForumDet fria alternativet

UserControl och säkerhet?

.NET

2 svar · 614 visningar · startad av CatZ

Medlem sedan jan. 20022 440 inlägg
Frågan#1

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

Medlem sedan mars 20023 561 inlägg
#2

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()]

Medlem sedan jan. 20022 440 inlägg
#3

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

257 ms totalt · 4 externa anrop · v20260731065814-full.86ec41c2
123 ms — deklarationer (db)
0 ms — hämta statistik (cache)
131 ms — hämta tråd, inlägg och bilagor (db)
123 ms — ändringar (db)