My MVC4 sites work without problems on 1 and 1 Internet shared hosting, but when I tried MVC5's default site using the VS2013 beta, it failed and I haven;t been able to figure out why. Can anyone help? Here are the error messages:
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() +47
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +66
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.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
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET >Version:4.0.30319.18044
In general, most applications should run fine under Medium Trust. If your application requires Full Trust, you can override the trust level at the application level by adding the following to your web.config file:
<configuration>
<system.web>
<trust level="Full" />
</system.web>
</configuration>
The ASP.NET team has killed support for medium trust. MVC 5 now requires full trust. See my answer at https://stackoverflow.com/a/17218344/59641 for more information.
Ask your hoster to run your site in full trust, or choose a different hoster.
Do they support ASP.NET 4.5.1 yet? The default MVC 5 template uses ASP.NET 4.5.1 which is still in beta as well. Can you target your project to the current ASP.NET 4.5 or 4?
Related
i currently updated my site asp.net 3.5 to 4.0. now i have found little problem when my site runs i found this error :
The requested script resource 'Seadragon.Seadragon.Config.js' requires version 'AjaxControlToolkit, Version=4.1.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' of the ASP.NET AJAX Framework. To use this resource, make sure that the application references version 'AjaxControlToolkit, Version=4.1.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The requested script resource 'Seadragon.Seadragon.Config.js' requires version 'AjaxControlToolkit, Version=4.1.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' of the ASP.NET AJAX Framework. To use this resource, make sure that the application references version 'AjaxControlToolkit, Version=4.1.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e'.
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:
[InvalidOperationException: The requested script resource 'Seadragon.Seadragon.Config.js' requires version 'AjaxControlToolkit, Version=4.1.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' of the ASP.NET AJAX Framework. To use this resource, make sure that the application references version 'AjaxControlToolkit, Version=4.1.7.1213, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e'.]
System.Web.UI.ScriptReference.GetUrlInternal(ScriptManager scriptManager, Boolean zip) +469796
System.Web.UI.ScriptReference.GetUrl(ScriptManager scriptManager, Boolean zip) +213
System.Web.UI.ScriptManager.RegisterUniqueScripts(List`1 uniqueScripts) +202
System.Web.UI.ScriptManager.RegisterScripts() +444
System.Web.UI.ScriptManager.OnPagePreRenderComplete(Object sender, EventArgs e) +122
System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +8872106
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2716
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1
You most likely have another version of the toolkit installed. Check your "packages" folder if you are using nuget
I comment the line on web.config
add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit"
It works for me.
History
In my development environment I've battled a reoccurring error with running Windows Azure Emulator. To resolve before I created a new Solution and projects based on the Azure template, along with reinstalling the October 2012 update SDK. Then I had to copy over all the files into the new projects. Before going through all that, since I know it can work, I wanted to see if there was something else I can do.
Setup
Windows 8
Visual Studio 2012 Update 1
IIS Express 8
Windows Azure Tools - October 2012
Windows Azure Caching 1.8.1.0
ASP.NET MVC 4.0 project
Web Role (2 Instances)
Cache Worker Role (2 Instances)
Caching Enabled on Cache Work Roles and set to Dedicated Role (Local Role state is: UseDevelopmentStorage=true)
Session uses Distributed Cache
Output Cache uses Distributed Cache
Web.config settings
<sessionState mode="Custom" customProvider="AFCacheSessionStateProvider" cookieName="abc_session">
<providers>
<add name="AFCacheSessionStateProvider" type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache" cacheName="default" dataCacheClientName="default" applicationName="AFCacheSessionState" />
</providers>
</sessionState>
<outputCache defaultProvider="AFCacheOutputCacheProvider">
<providers>
<add name="AFCacheOutputCacheProvider" type="Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider, Microsoft.Web.DistributedCache" cacheName="default" dataCacheClientName="default" applicationName="AFCacheOutputCache" />
</providers>
</outputCache>
</caching>
<dataCacheClients>
<dataCacheClient name="default">
<autoDiscover isEnabled="true" identifier="AppNameCacheWorkerRole" />
</dataCacheClient>
</dataCacheClients>
Error Details
ErrorCode<ERRCA0009>:SubStatus<ES0001>:Cache referred to does not exist
[DataCacheException: ErrorCode<ERRCA0009>:SubStatus<ES0001>:Cache referred to does not exist. Contact administrator or use the Cache administration tool to create a Cache.]
Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ErrStatus errStatus, Guid trackingId, Exception responseException, Byte[][] payload, EndpointID destination) +767
Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ResponseBody respBody, EndpointID destination) +149
Microsoft.ApplicationServer.Caching.DataCacheFactory.EstablishConnection(IEnumerable`1 servers, RequestBody request, Func`3 sendMessageDelegate, DataCacheReadyRetryPolicy retryPolicy) +967
Microsoft.ApplicationServer.Caching.<>c__DisplayClass4.<Initialize>b__1(RequestBody req) +198
Microsoft.ApplicationServer.Caching.SocketClientProtocol.SendReceive(IVelocityRequestPacket request, Func`2 delegate, EndpointID& destination) +121
Microsoft.ApplicationServer.Caching.SocketClientProtocol.Initialize(IEnumerable`1 servers) +1011
Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName, CreateNewCacheDelegate cacheCreationDelegate, DataCacheInitializationViaCopyDelegate initializeDelegate) +1103
Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName) +131
Microsoft.Web.DistributedCache.DataCacheFactoryWrapper.CreateDataCacheFromFactory(DataCacheFactory factory, String cacheName) +63
Microsoft.Web.DistributedCache.CacheHelpers.RunCacheCreationHooks(CacheConnectingEventArgs fetchingEventArgs, IDataCacheFactory dataCacheFactory, Object sender, EventHandler`1 fetchingHandler, EventHandler`1 fetchedHandler) +356
Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider.CreateInternalProvider(IHttpRuntime httpRuntime, OutputCacheInitializationData initData, IDataCacheFactory dataCacheFactory, EventHandler`1 cacheFetching, EventHandler`1 cacheFetched) +399
Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider.GetInternalProvider() +315
Microsoft.Web.DistributedCache.DistributedCacheOutputCacheProvider.Get(String key) +54
System.Web.Caching.OutputCache.Get(String key) +80
System.Web.Caching.OutputCacheModule.OnEnter(Object source, EventArgs eventArgs) +341
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165
Misc Notes:
The same configuration works fine when it is deployed to Azure, so has something to do with my local environment.
IIS Express was crashing when I had more than one instance of web roles setup, and I found a suggestion to run the Visual Studio 2010 SP1 to resolve. I had VS2010 on the system because one tools (believe it was SQL) installed it. Installing SP1 resolved the issue with IIS Express crashing, but then this error reappeared.
If I comment out the OutputCache node listed above the error goes away.
If I switch the Cache Worker Role from Dedicated Role to Co-located Role the error goes away.
Spoke with Microsoft tech support and it appears this a known issue. Most of the time it can be resolved by forcing a refresh in the browser. I've had mixed success. The fix for this issue will be part of the next Azure SDK release.
This happens to me in production a lot! I upload my package to staging first, and have to always wait until all the instances are running before hitting the staging URL. Sometimes this error still occurs and I restart all my instances for it to fix itself.
The weirdest thing. I am switching over to SDK v1.7 and a new ACS and I get this weird error after I successfully login. It appears to be related to the SessionState provider for the Azure Cache Service.
I am NOT using the Preview but I am using SDK 1.7 and I am using a Windows Azure account that has the Preview Features enabled.
It's like something deep within the recesses of the ACS/Cache Service SDK is messed up.
Here is my cache config:
<dataCacheClients>
<dataCacheClient name="default">
<tracing sinkType="DiagnosticSink" traceLevel="Verbose" />
<hosts>
<host name="[[newCacheNamespace]].cache.windows.net" cachePort="22233" />
</hosts>
<securityProperties mode="Message">
<messageSecurity authorizationInfo="[[secret]]">
</messageSecurity>
</securityProperties>
</dataCacheClient>
<dataCacheClient name="SslEndpoint">
<tracing sinkType="DiagnosticSink" traceLevel="Verbose" />
<hosts>
<host name="[[newCacheNamespace]].cache.windows.net" cachePort="22243" />
</hosts>
<securityProperties mode="Message" sslEnabled="true">
<messageSecurity authorizationInfo="[[secret]]">
</messageSecurity>
</securityProperties>
</dataCacheClient>
</dataCacheClients>
Here is my session state provider config:
<sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
<add name="AppFabricCacheSessionStoreProvider" type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache" cacheName="default" useBlobMode="true" dataCacheClientName="default" />
</providers>
</sessionState>
Below is the error that I get:
Server Error in '/' Application.
--------------------------------------------------------------------------------
The remote name could not be resolved: '[[oldCacheNamespace]]-cache.accesscontrol.windows.net'
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The remote name could not be resolved: '[[oldCacheNamespace]]-cache.accesscontrol.windows.net'
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:
[WebException: The remote name could not be resolved: '[[oldCacheNamespace]]-cache.accesscontrol.windows.net']
System.Net.WebClient.UploadValues(Uri address, String method, NameValueCollection data) +1243
System.Net.WebClient.UploadValues(String address, String method, NameValueCollection data) +179
Microsoft.ApplicationServer.Caching.AcsHelpers.GetToken(String serviceNamespace, String acsHostName, String issuerName, String issuerKey, String appliesTo) +523
[DataCacheException: ErrorCode<ERRCA0030>:SubStatus<ES0001>:ACS request for token failed. One of the reasons could be an invalid authorization token.]
Microsoft.ApplicationServer.Caching.AcsHelpers.GetToken(String serviceNamespace, String acsHostName, String issuerName, String issuerKey, String appliesTo) +1875
Microsoft.ApplicationServer.Caching.ClientAcsSecurity.get_Token() +242
Microsoft.ApplicationServer.Caching.CacheResolverChannel..ctor(CacheResolverCommunicatorType communicatorType, IDuplexSessionChannel innerChannel, DataCacheSecurity dataCacheSecurity) +559
[CommunicationException: ErrorCode<ERRCA0030>:SubStatus<ES0001>:ACS request for token failed. One of the reasons could be an invalid authorization token.]
Microsoft.ApplicationServer.Caching.CacheResolverChannel..ctor(CacheResolverCommunicatorType communicatorType, IDuplexSessionChannel innerChannel, DataCacheSecurity dataCacheSecurity) +833
Microsoft.ApplicationServer.Caching.CacheResolverChannelFactory`1.System.ServiceModel.Channels.IChannelFactory<TChannel>.CreateChannel(EndpointAddress to) +274
Microsoft.ApplicationServer.Caching.EndPointIdentityChannelFactory`1.System.ServiceModel.Channels.IChannelFactory<TChannel>.CreateChannel(EndpointAddress to) +186
Microsoft.ApplicationServer.Caching.WcfClientChannel.CreateChannel(EndpointID endpoint) +557
Microsoft.ApplicationServer.Caching.ChannelContainer.CreateChannel() +153
[DataCacheException: ErrorCode<ERRCA0017>:SubStatus<ES0006>:There is a temporary failure. Please retry later. (One or more specified cache servers are unavailable, which could be caused by busy network or servers. For on-premises cache clusters, also verify the following conditions. Ensure that security permission has been granted for this client account, and check that the AppFabric Caching Service is allowed through the firewall on all cache hosts. Also the MaxBufferSize on the server must be greater than or equal to the serialized object size sent from the client.)]
Microsoft.ApplicationServer.Caching.DataCache.ThrowException(ResponseBody respBody) +693
Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCacheProperties(RequestBody request, SimpleSendReceiveModule sendRcvModule) +1194
Microsoft.ApplicationServer.Caching.DataCacheFactory.GetCache(String cacheName) +701
Microsoft.Web.DistributedCache.DataCacheFactoryWrapper.CreateDataCacheFromFactory(DataCacheFactory factory, String cacheName) +63
Microsoft.Web.DistributedCache.CacheHelpers.RunCacheCreationHooks(CacheConnectingEventArgs fetchingEventArgs, IDataCacheFactory dataCacheFactory, Object sender, EventHandler`1 fetchingHandler, EventHandler`1 fetchedHandler) +356
Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.CreateInternalProvider(IHttpRuntime httpRuntime, SessionInitializationData initData, IDataCacheFactory dataCacheFactory, EventHandler`1 cacheFetching, EventHandler`1 cacheFetched) +447
Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.GetInternalProvider() +315
Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider.CreateNewStoreData(HttpContext context, Int32 timeout) +59
System.Web.SessionState.SessionStateModule.InitStateStoreItem(Boolean addToContext) +182
System.Web.SessionState.SessionStateModule.CompleteAcquireState() +374
System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +2007
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +477
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +312
This is an old question, but someone might run into this problem in the future.
The fix is:
Remove the < hosts> element.
Instead, add this element:
< autoDiscover isEnabled="true" identifier="[[newCacheNamespace].cache.windows.net" />
That's it
When trying to create custom performance counters as explained in this MSDN article, I still get a security exception.
The code I am using is the same as in that article, only I am creating a different counters.
I understand that I can try to create it in a start-up task, but for now I want to do it inside the role.. it should work :/
The exception:
[SecurityException: Requested registry access is not allowed.]
Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) +12746267
System.Diagnostics.PerformanceCounterLib.CreateRegistryEntry(String categoryName, PerformanceCounterCategoryType categoryType, CounterCreationDataCollection creationData, Boolean& iniRegistered) +170
System.Diagnostics.PerformanceCounterLib.RegisterCategory(String categoryName, PerformanceCounterCategoryType categoryType, String categoryHelp, CounterCreationDataCollection creationData) +49
System.Diagnostics.PerformanceCounterCategory.Create(String categoryName, String categoryHelp, PerformanceCounterCategoryType categoryType, CounterCreationDataCollection counterData) +558
The beginning of my ServiceDefinition.csdef:
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="Jonathan.Cloud" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="WebDriver" vmsize="Small" enableNativeCodeExecution="true">
<Runtime executionContext="elevated" />
When I RDP into the role, I can see that the application pool is still running with the NetworkService identity, was expecting it to run under a different principal as I changed the role to be 'elevated' - manually setting up a custom principal with permissions solves this, but it will be over-ridden once the role reconfigure itself or if I deploy an upgrade - in any case, this is not really a solution but a hack :/ [frustrated]
In the case of Web Role of Full IIS, the special privilege which you appointed in Runtime element is applied to RoleEntoryPoint. I think that it is necessary to register a custom performance counter by inner RoleEntryPoint (usually WebRole.cs) OnStart method.
We have an assembly using a refernce to the Automapper.dll. Starting the NServiceBus as Subscriber fails on Start with the following message:
Exception when starting endpoint, error has been logged. Reason: Could not load file or assembly 'file:///D:\Main\Src\Core\Core.MessageHandler\bin\Debug\AutoMapper.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
StackTrace:
Server stack trace:
at Magnum.StateMachine.ExceptionActionDictionary`1.HandleException(T stateMachine, Event event, Object parameter, Exception exception)
at Magnum.StateMachine.EventActionList`1.Execute(T stateMachine, Event event, Object parameter)
at Magnum.StateMachine.EventActionBase`1.Execute(T instance, Event event, Object parameter)
at Magnum.StateMachine.State`1.RaiseEvent(T instance, BasicEvent`1 eevent, Object value)
at Magnum.StateMachine.StateMachine`1.RaiseEvent(Event raised)
at Topshelf.Internal.ServiceController`1.Start()
at Topshelf.Internal.IsolatedServiceControllerWrapper`1.Start()
at Topshelf.Internal.ServiceControllerProxy.Start()
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Topshelf.Internal.ServiceControllerProxy.Start()
at Topshelf.Internal.FacadeToIsolatedServiceController`1.Start()
at Topshelf.Internal.ServiceCoordinator.Start()
at Topshelf.Internal.Hosts.ConsoleHost.Run()
at Topshelf.Internal.Actions.RunAsConsoleAction.Do(IRunConfiguration configuration)
at Topshelf.Runner.Host(IRunConfiguration configuration, String[] args)
at NServiceBus.Host.Program.Main(String[] args)
The file "Automapper.dll" exists! There is no problem in the Config. I checked this removing the dependency to the AutoMapper.dll and it works.
Here is the config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="MsmqTransportConfig"
type="NServiceBus.Config.MsmqTransportConfig, NServiceBus.Core" />
<section name="Logging" type="NServiceBus.Config.Logging, NServiceBus.Core" />
</configSections>
<MsmqTransportConfig
InputQueue="MyQueue#localhost"
NumberOfWorkerThreads="1"
MaxRetries="10"
ErrorQueue="ErrorQueue#localhost" />
<Logging Threshold="WARN" />
</configuration>
Any idea? Are there known problems with AutoMapper dependencies in NServiceBus?
In your endpoint configuration class (IConfigureThisEndpoint) it's common to implement IWantCustomInitialization as well. As part of that custom initialization you can specify the following:
public void Init()
{
Configure.With(AllAssemblies.Except("Automapper.dll"))
.AutofacBuilder()
.Log4Net(); // etc.
}
The "AllAssemblies.Except()" code instructs the NServiceBus configuration to completely ignore the Automapper assembly.
One other potential issue that may cause the issue is if you're using NServiceBus.Host.exe compiled against the CLR v2.0 (.NET v3.5) while Automapper is compiled against the CLR v4.0 (.NET 4.0). There are several builds of NServiceBus depending upon your CLR version. You may need to try running the CLR v4.0 version of change Automapper to be the .NET 3.5 version (which I believe isn't actively developed).
We had to use a binding redirect to get Autofac + NServiceBus to work. I believe the NServiceBus.ObjectBuilder.Autofac2.dll we referenced used an older version of Autofac than we were using.
app.config:
...
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" />
<bindingRedirect oldVersion="2.3.2.632" newVersion="2.4.3.700" />
</dependentAssembly>
</assemblyBinding>