error 500: ManagedPipelineHandler, deploying web api mvc 4 on azure - azure

I'm trying to deploy a WebAPI project to azure.
When I have a method without SQL access, it shows the result properly as JSON in my browser.
However, when I do anything using Entity framework and just get a test field from the DB then the whole thing errors:
Module ManagedPipelineHandler
Notification ExecuteRequestHandler
Handler System.Web.Http.WebHost.HttpControllerHandler
Error Code 0x00000000
Things I tried:
When running in the 'Azure compute emulator' everything runs just fine
When using the exact same sql azure connection string in debug it runs just fine
When connecting with RDP to the webrole and telnetting to port 1443 to the SQL azure server, it connects just fine. (so no firewall issue).
What could I try next to find out what is causing this?
Update:
When I point the connectionstring to a local SQLEXPRESS db, it gives the same error. On the local azure emulator it still works
Update:
Screenshot of error which is displayed on a local browser (via rdp)
http://www.proofofconcept.nl/azure_error_screenshot.png
Update:
By popular request. The web.config used
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
-->
<configuration>
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
<add name="Entities" connectionString="metadata=res://*/DAL.Coalition.csdl|res://*/DAL.Coalition.ssdl|res://*/DAL.Coalition.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
<!--
<add name="ApplicationServices" connectionString="data source=acbdefgh12.database.windows.net;Initial Catalog=MyCatalog;User ID=database_user#acbdefgh12;Password=MyPassword;Encrypt=true;Trusted_Connection=false;MultipleActiveResultSets=True" providerName="System.Data.SqlClient"/>
<add name="Entities" connectionString="metadata=res://*/DAL.Coalition.csdl|res://*/DAL.Coalition.ssdl|res://*/DAL.Coalition.msl;provider=System.Data.SqlClient;provider connection string="data source=acbdefgh12.database.windows.net;Initial Catalog=MyCatalog;User ID=database_user#acbdefgh12;Password=MyPassword;Encrypt=true;Trusted_Connection=false;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
-->
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="1.0.0.0" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<customErrors mode="Off" />
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear />
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

Are you using EF CodeFitst? If so which version? (versions prior 4.3 do have issues with SQL Azure)? Then observe following conditions:
Is your main DbContext named "Entities" or do you explicitly create it with constructor overload which points to "Entities" Connection?
Does your my_dbuser#acbdefgh12 user have access rights to the MASTER DB?
Does the MyCatalog exists prior you deploy the package?
Does your SQL Azure Firewall rules "Allow connections from other Windows Azure Services" (take a look at the screenshot bellow) (I know you mentioned it, but anyway)?
I've been seeing exactly same error when either is true:
my_dbuser#acbdefgh12 does not have access to the Master DB to create the MyCatalaog DB (in case it does not exists)
MyCatalog DB exists but is different from the DbContext model
The main DbContext is named differently than Entities and is created with default parameterless constructor (which in that case uses default EF connection string)
SQL Azure server is not configured to accept connections from other Windows Azure Services
The actual error unfortunately does not show anything useful. As I said I've been seeing exactly the same error when failed to comply with above statements.
What can I suggest to trace the error is to hook / edit your auto generated DbContext file and explicitly throw an exception with the connection string being used just before the connection is open to make sure of the connection string being used.
UPDATE AFTER OVERLOOKING GIVEN Web.Config
Not sure whether this is relevant but I noted that in your web.config the assemblybindings are forcing use of MVC 3.0 if version is lower:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
While instead my web.config for MVC 4 is slightly different for the Web API project type (.NET FX 4.0 / MVC 4):
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

Very old question, but my issue fairly quickly led me to this page. On an Azure webapp, Entity Framework application I had a 500 error and had a lot of trouble getting any additional information from the logs and traces.
It turns out that my connection string was missing the
MultipleActiveResultSets=true;
attribute. Some pages were working and others were not. Once I added this in, all pages were working.

Related

HTTP Error 500.19 - Internal Server Error - Error Code 0x80070490 - IIS 7.5 ( Works on Azure )

I am executing my code in the Azure emulators. The code I have built is Thinktecture's IdentityServer2. After the emulators start running and everything is ready I get an error when I fire the URL in the browser. There is another SO thread about this issue. But the solutions don't seem to apply to my Web.Config
There is no URL rewrite module rule
Default website in IIS manager has pass-through authentication. What is this ?
Gave full control to users to access wwwroot.
virtual folder>basic settings> Connect As > Path credentials has pass-through authentication
What else should I do ?
Web.Config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<section name="thinktecture.identityServer.repositories" type="Thinktecture.IdentityServer.Configuration.RepositoryConfigurationSection, Thinktecture.IdentityServer.Core" />
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<!-- ............................................... -->
<!-- start of identity server relevant configuration -->
<thinktecture.identityServer.repositories configSource="configuration\repositories.config" />
<system.identityModel configSource="configuration\identity.config" />
<system.identityModel.services configSource="configuration\identityServices.config" />
<connectionStrings configSource="configuration\connectionStrings.config" />
<system.diagnostics configSource="configuration\tracing.config" />
<location path="account/certificatesignin">
<system.webServer>
<security>
<access sslFlags="Ssl, SslNegotiateCert, SslRequireCert" />
</security>
</system.webServer>
</location>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<diagnostics>
<messageLogging logMessagesAtTransportLevel="true" logEntireMessage="true" logMalformedMessages="true" />
</diagnostics>
</system.serviceModel>
<appSettings>
<add key="idsrv:CreateTestDataOnInitialization" value="true" />
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="RoleManager" />
<add name="SessionAuthenticationModule" type="System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</modules>
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
<system.web>
<customErrors mode="RemoteOnly" />
<globalization enableClientBasedCulture="true" uiCulture="auto" culture="auto" />
<profile configSource="configuration\profile.config" />
<compilation debug="true" targetFramework="4.5" />
<authentication mode="Forms">
<forms loginUrl="~/account/signin" />
</authentication>
<pages>
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="ProviderDB" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<roleManager enabled="true" defaultProvider="DefaultRoleProvider">
<providers>
<add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="ProviderDB" applicationName="/" />
</providers>
</roleManager>
<sessionState mode="Off"></sessionState>
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
<parameters>
<parameter value="System.Data.SqlServerCe.4.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.4.0" />
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>
</system.data>
</configuration>
Error
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Detailed Error Information:
Module CustomErrorModule
Notification SendResponse
Handler Not yet determined
Error Code 0x80070490
Config Error The configuration section 'system.webServer/httpErrors' cannot be read because it is missing a section declaration
Config File \\?\C:\Users\User1\AppData\Local\dftmp\Resources\95c4e530-03a7-4e9f-b0c5-152a2cd71ccf\temp\temp\RoleTemp\applicationHost.config
Note
This error occurs when there is a problem reading the configuration file for the Web server or Web application. In some cases, the event logs may contain more information about what caused this error.
Fix attempt 1
Doesn't work.
<httpErrors errorMode="Custom" existingResponse="Replace">
<!--Remove inherited 500 error page setting -->
<remove statusCode='404' subStatusCode='-1'/>
<!--Override the inherited 500 error page setting with the 'My500.html' as its path-->
<error statusCode='404' subStatusCode='-1' prefixLanguageFilePath='' path='/home/index' responseMode='ExecuteURL'/>
</httpErrors>

How to repair IISExpress that wont compile simple application?

If I create a new empty MVC application, add a controller and a view and then run I get a compile error which appears to be from IISExpress as it doesn't show as an error in Visual Studio.
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.
Compiler Error Message: BC30451: 'ViewData' is not declared. It may be
inaccessible due to its protection level.
Source Error:
Line 1: #Code
Line 2: ViewData("Title") = "Index"
Line 3: End Code
The Views web.config appears to be correct as it contains the various required namespace:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="MVCAjaxWorkbench" />
</namespaces>
</pages>
</system.web.webPages.razor>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.webServer>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>
and the main web.config appears to be correct as well:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=301880
-->
<configuration>
<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>
<compilation debug="true" targetFramework="4.5.1"/>
<httpRuntime targetFramework="4.5.1"/>
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<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="1.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.WebPages" 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.1.0.0" newVersion="5.1.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
I think that something has gone wrong with my installation of IISExpress. I've reviewed the options for using IIS instead of IISExpress and I really would much prefer to stick with IISExpress but simply reinstalling it has made no difference. My next step is to try reinstalling Visual Studio but I'd rather avoid that if possible as it tends to have side effects of its own.
How can I repair my IISExpress installation so that it functions correctly with Visual Studio?
I actually managed to get this working myself by doing the following:
Uninstall IISExpress
Run a 'Repair' installation of Visual Studio 2013
Clean the solution and set Copy Local = True in the properties of the references for System.Web.MVC (following some of the answers in this question)
Using the Package Manager dialog do an update of all MS and .NET DLLs
Update JQuery and Bootstrap (only as a result of updating the DLLS)
I can't tell which of those was the crucial step although I suspect it was setting Copy Local = True but an MS update appears to be the source of the problem.

Azure Website ASP.net WebPages "The page cannot be displayed because an internal server error has occurred."

I've developed an application in WebPages and im hosting the website on Azure. Its giving me the error "The page cannot be displayed because an internal server error has occurred."
I'm not sure what i'm doing wrong.
Heres the Web.config file.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Webpages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5" />
<customErrors mode="Off"/>
</system.web>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.4.0" />
<add invariant="System.Data.SqlServerCe.4.0" name="Microsoft® SQL Server® Compact 4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>
</system.data>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="2.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<connectionStrings><add name="SQLAzure" connectionString="Data Source=###;Initial Catalog=###;User ID=### ;Password=###;Encrypt=true;Trusted_Connection=false;" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
If I remove the assemblyBindings "Could not load file or assembly 'System.Web.Helpers'" error pops up. Any help would be great, thanks.
If you are using Visual Studio, you should be able to determine the error by remote debugging your Azure web site
Here is another troubleshooting reference if you aren't using Visual Studio
Azure Websites have System.Web.Helpers, Version=1.0.0.0 and your web.config refers to Version=2.0.0.0.
Yes you can copy the correct version from your GAC to bin , but this is not optimal solution, because you have to upload binaries to Azure and that is not you job.
The best solution is use NuGet package manager.
You can do it from your visual studio
run the following command in the Package Manager Console Install-Package microsoft-web-helpers

Want implement cache in web role in azure emulator 1.8 for local and deployment

Want implement cache in web role cache in azure emulator 1.8 for local and deployment.
I try many codes but not working
web.config file settings
I am testing this code on visual studio 2012 with azure emulator 1.8 version.
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<!-- Append below entry to configSections. Do not overwrite the full section. -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="dataCacheClients" type="Microsoft.ApplicationServer.Caching.DataCacheClientsSection, Microsoft.ApplicationServer.Caching.Core" allowLocation="true" allowDefinition="Everywhere" />
</configSections>
<system.diagnostics>
<trace>
<listeners>
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-WebRole1-20130503143610;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-WebRole1-20130503143610.mdf" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<pages>
<namespaces>
<add namespace="System.Web.Optimization" />
</namespaces>
<controls>
<add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
</controls>
</pages>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" defaultUrl="~/" />
</authentication>
<profile defaultProvider="DefaultProfileProvider">
<providers>
<add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</profile>
<membership defaultProvider="DefaultMembershipProvider">
<providers>
<add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>
</membership>
<roleManager defaultProvider="DefaultRoleProvider">
<providers>
<add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
</providers>
</roleManager>
<!--
If you are deploying to a cloud environment that has multiple web server instances,
you should change session state mode from "InProc" to "Custom". In addition,
change the connection string named "DefaultConnection" to connect to an instance
of SQL Server (including SQL Azure and SQL Compact) instead of to SQL Server Express.
-->
<sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider" timeout="30">
<providers>
<add name="AppFabricCacheSessionStoreProvider"
type="Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider, Microsoft.ApplicationServer.Caching.Client, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
cacheName="default"/>
</providers>
</sessionState>
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.ApplicationServer.Caching.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.ApplicationServer.Caching.Core" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
<dataCacheClients>
<dataCacheClient name="default">
<hosts>
<host name="localhost" cachePort="22233" />
</hosts>
<!--<securityProperties mode="Message">
<messageSecurity authorizationInfo="e58a8dbc-5093-4124-b5fd-9b9538d72213"></messageSecurity>
</securityProperties>-->
</dataCacheClient>
</dataCacheClients>
</configuration>
------------------------------------------------------------------
Coding for test cache
public partial class _Default : Page
{
DataCacheFactory myFactory;
DataCache myCache;
Random randomizer = new Random();
protected void Page_Load(object sender, EventArgs e)
{
myFactory = new DataCacheFactory();
myCache = myFactory.GetDefaultCache();
string Test = "Test1";
myCache.Put("MyKey", Test);
}
}
Start by reading About Windows Azure Caching then read Windows Azure Caching on Existing Roles. There are links to samples and plenty of code examples in the documentation. Your config is for a cache that doesn't exist - cachePort="22233" is for the old Azure Fabric Shared Cache and can't be used with localhost.

ASP.NET MVC 2 & IIS : HTTP 500.24 favicon.ico Error

I have a little weird behavior with my ASP.NET MVC 2 application.
I'm using IIS 7.5, Windows Authentication and ASP.NET Impersonation for my webpage to load.
After several searches, I didn't found a nice way to get rid of the 500.24 Request that I keep getting on every page load (The favicon.ico at the root directory triggers this) :
I've looked at some articles like this one or that one but this doesn't seems to solve my issue. I need these settings on for my application to work here : .NET 4 Framework Integrated Mode pipeline, Windows Authentification and ASP.NET Impersonation.
Here's a simplified version of my web.config, if it can help anyone (of course, I've removed the connections strings for security reasons..)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<customErrors mode="Off" />
<identity impersonate="true" />
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<authentication mode="Windows">
<!-- roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider" / -->
<!-- forms loginUrl="~/Account/LogOn" timeout="2880" / -->
</authentication>
<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/Globe" />
</providers>
</membership>
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/Globe" />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear />
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/Globe" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/Globe" />
</providers>
</roleManager>
<pages>
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-UA-Compatible" value="IE=edge" />
</customHeaders>
</httpProtocol>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
<remove name="WebDAVModule" />
</modules>
<security>
<requestFiltering>
<verbs>
<add verb="PUT" allowed="true" />
<add verb="DELETE" allowed="true" />
</verbs>
</requestFiltering>
</security>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
</configuration>
My application IS working, the favicon.ico IS loading, I'm just wondering why it does fires a 500.24 on every request (Of course, maybe it's Fiddler who can't authenticate itself and causes de 500.24 HTTP Error, but when it does normally it triggers a 401.2 - Unauthorized instead...)
My guess is that favicon.ico is either running in a different application pool, or there is a web.config in the root of the site that has issues.
So:
1) Check to see if the root of the site (the directory where /favicon.ico lives) includes a web.config. If it does, then check to see if it is setting a system.web/httpModule, or httpHandler, or system.web/identity (impersonate) or something like that, and the application pool is running in integrated mode.
So what you need to do is either remove the offending httpmodule/httphandler/impersonate setting, or change the application pool to run as classic, or add the same configuration your site includes which is <validation validateIntegratedModeConfiguration="false" />
What CarlosAg said. Cheap fix might be to move the favicon into the offended app rather than barking up the tree.
I did find the answer to my problem =)
You're gonna laugh at me, for sure.. =P
Well, part of the answer is the <validation validateIntegratedModeConfiguration="false" /> in the C:\inetpub\wwwroot that CarlosAg pointed out, but the other part was that I simply forgot to add the <link rel="icon" href="<%: Url.Content("~/favicon.ico")%>" type="image/x-icon" /> to my Site.Master file in my ASP.NET MVC 2 Application. Since Chrome and IE does look at the root directory for a favicon.ico, it appeared to work, but I didn't notice until now that Firefox wasn't loading up the favicon.
Now the favicon loads on every browser, and there is no 500.24 HTTP Request sent over in Fiddler.
Thanks ! =)

Resources