11.886 messaggi dal 09 febbraio 2002
Contributi
Ciao, prego.
esatto, la security exception puoi evitarla commentando <system.codedom>. Se rifai il deploy ottieni ancora lo stesso errore? In questo caso prova a commentare anche <system.webServer>, che è il nodo di configurazione di IIS. Inoltre, commenta anche l'eventuale nodo <httpModules>.

Se questo non basta a risolvere il problema, potrebbe essere che stai usando una versione del .NET Framework troppo recente. Aruba dice di supportare ASP.NET 4.5, quindi durante la creazione del template seleziona anche tu ASP.NET 4.5. Lo vedi là in alto in questa immagine, c'è un menu a tendina da cui puoi selezionare la versione .NET Framework 4.5.

Fatto questo, non dovrebbe esserci più nulla a creare fastidio ad Aruba. In caso contrario, posta l'errore.


mi consigli di cambiare hosting?

No, scegli tu liberamente che hosting utilizzare. Risolti questi fastidi iniziali, anche su Aruba l'applicazione dovrebbe funzionare bene.
Ricordati sempre di usare la funzione "Publish..." di Visual Studio e di trasferire nel server solo i file contenuti nella cartella di pubblicazione.

ciao,
Moreno

Enjoy learning and just keep making
10 messaggi dal 04 marzo 2018
Allora, ho fatto
New => Progetto => Visual C# / Web => ASP.NET Web Application (Net Framework)
selezionando in alto il 4.5

pubblicato via FTP direttamente da Visual Studio
(specifico per conferma non debba fare in due passi come mi indicavi)

Errore
Server Error in '/' Application.
quindi aggiunto
<customErrors mode="Off"/>


e torno a [SecurityException: Request failed.]

Commentato
<system.codedom>
...
</system.codedom>


mi da [SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission ...
(vedi sotto)

Commentato
<system.webServer>
...
</system.webServer>

e
<httpModules>
...
</httpModules>


l'errore attuale rimane il precedente, che riporto qui:

[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) +115
   Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +106
   System.Web.HttpApplication.InitModulesCommon() +166
   System.Web.HttpApplication.InitModules() +64
   System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +792
   System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +336
   System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +107
   System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +525


ho quindi cercato System.Security.Permissions.ReflectionPermission
ma non trovo risultati qui.

via google, trovo solo questo link inquietante:
https://social.msdn.microsoft.com/Forums/it-IT/6df65f37-d969-404f-8328-f144b75206d1/problema-trust-level-autenticazione-server-aruba?forum=aspnetit

ho provato anche in system.web:
<trust level="Full" />


ma mi dava solo:
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.


tengo i 3 tag commentati e tolgo trust level full.

questo è il web.config (sperando non ci sia nulla da censurare :) )
<?xml version="1.0" encoding="utf-8"?>
<!--
  Per altre informazioni su come configurare l'applicazione ASP.NET, vedere
  https://go.microsoft.com/fwlink/?LinkId=301880
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-MvcMovies3-20180305112047.mdf;Initial Catalog=aspnet-MvcMovies3-20180305112047;Integrated Security=True"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <authentication mode="None" />
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <!--<httpModules>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
    </httpModules>-->
    <customErrors mode="Off"/>
  </system.web>
  <!--
  <system.webServer>
    <modules>
      <remove name="FormsAuthentication" />
      <remove name="ApplicationInsightsWebTracking" />
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
    </modules>
    <validation validateIntegratedModeConfiguration="false" />
  </system.webServer>
  -->
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.1.0" newVersion="3.0.1.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="mssqllocaldb" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>
  </entityFramework>
  <!--
  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
      <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\"Web\" /optionInfer+" />
    </compilers>
  </system.codedom>
  -->
</configuration>

Modificato da jackIT il 05 marzo 2018 23.47 -
10 messaggi dal 04 marzo 2018
PS per modificare il web.config ho fatto da visual studio e ripubblicato tutto. posso andare anche direttamente via FTP? oppure nascono altri problemi? grazie
11.886 messaggi dal 09 febbraio 2002
Contributi
Ciao,
prova a pubblicare questo progetto che ho fatto io. Ho rimosso tutto quello che può dare fastidio e ho verificato che funzionasse in regime di Medium Trust sul mio IIS locale.
https://1drv.ms/u/s!Ao4rhSdtDw8rge0WZbSmLljoaQLVLw


PS per modificare il web.config ho fatto da visual studio e ripubblicato tutto. posso andare anche direttamente via FTP? oppure nascono altri problemi? grazie

Sì, puoi apportare modifiche al web.config e ripubblicare solo quello. IIS si accorgerà che il web.config è cambiato e ricaricherà l'applicazione con le nuove impostazioni.

ciao,
Moreno

Enjoy learning and just keep making
10 messaggi dal 04 marzo 2018
Sono due giorni che bramavo per fare questo test...
e...

FUNZIONA!!!

grazie mille!

posso chiederti come?
non posso sfruttare la struttura di Login che mi prepara Visual Studio?

grazie davvero!
11.886 messaggi dal 09 febbraio 2002
Contributi
Ciao, prego.


non posso sfruttare la struttura di Login che mi prepara Visual Studio?

Forse sì ma va verificato e casomai vanno rimosse le parti che causano problemi in medium trust.
Microsoft ha consigliato, ormai svariati di anni fa, di NON usare il medium trust come strategia di isolamento delle applicazioni.
https://support.microsoft.com/en-us/help/2698981/asp-net-partial-trust-does-not-guarantee-application-isolation
Si legge:

We are updating our guidance about this to reflect that running an ASP.NET page framework application in partial trust does not guarantee complete isolation from other applications that are running in the same process or on the same computer.
...
Configuring ASP.NET page framework applications to run in separate low-privileged processes (by using individual application pools) is the recommended procedure to make sure of isolation from other ASP.NET page framework applications on the same web server.

Quindi, imporre il medium trust è una pratica morta e sepolta.
Nel creare nuove tecnologie, come Roslyn e ASP.NET Identity, Microsoft dà per assodato che gli hosting provider l'abbiano capito.
Con Aruba hai la possibilità di farti spostare su un server in cui hai il Full Trust e potrebbero farti firmare qualcosa per assumerti la responsabilità che non causerai danni. A quel punto puoi far funzionare il template di Visual Studio tale e quale, senza dover apportare modifiche.

Personalmente resto incredulo del fatto che questa situazione non sia mai cambiata nel corso degli anni. Io non firmerei mai una lettera di assunzione di responsabilità, dato che garantire un ambiente sicuro è una responsabilità dell'hosting provider e non dovrebbe essere scaricata sui clienti.

ciao,
Moreno

Enjoy learning and just keep making
10 messaggi dal 04 marzo 2018
Personalmente resto incredulo del fatto che questa situazione non sia mai cambiata nel corso degli anni. Io non firmerei mai una lettera di assunzione di responsabilità, dato che garantire un ambiente sicuro è una responsabilità dell'hosting provider e non dovrebbe essere scaricata sui clienti.


concordo a pieno e mi inquieta anche un po'.

posso chiederti partendo da un progetto base nuovo, cosa hai rimosso per farlo girare in medium trust?
grazie mille
11.886 messaggi dal 09 febbraio 2002
Contributi
Strano ma vero, il problema erano gli action link che si trovano nella barra del menu, nel file _Layout.cshtml.
<ul class="nav navbar-nav">
  <li>@Html.ActionLink("Home", "Index", "Home")</li>
  <li>@Html.ActionLink("Chi siamo", "About", "Home")</li>
  <li>@Html.ActionLink("Contatti", "Contact", "Home")</li>
</ul>


Molto probabilmente, ASP.NET MVC usa la reflection per ottenere un riferimento alle action a cui si riferiscono le stringhe che sono usate come parametri dell'action link. E come si legge qui:

Medium trust applications have no registry access, no event log access, and no ability to use reflection


Ho potuto scoprire che il problema era quello guardando lo stack trace della SecurityException.
Probabilmente anche Entity Framework (code first) ti sarà precluso in Medium Trust per lo stesso motivo.
http://forum.aspitalia.com/forum/post/389445/EntityFramework-Medium-Trust-Per-Hosting-Aruba.aspx

ciao,
Moreno
Modificato da BrightSoul il 10 marzo 2018 13.25 -

Enjoy learning and just keep making

Torna al forum | Feed RSS

ASPItalia.com non è responsabile per il contenuto dei messaggi presenti su questo servizio, non avendo nessun controllo sui messaggi postati nei propri forum, che rappresentano l'espressione del pensiero degli autori.