ASP.NET application restarting for no apparent reason - c#

I know this issue has been brought up a lot, but no matter what I try, it just doesn't seem to solve my issue.
My ASP.NET Web Forms application keeps restarting at what appears to be completely random time intervals, although they seem to normally range between 30 to 60 minutes. I most recently tried to run the application in ServerState instead of InProc, but this did nothing to solve the problem.
There does not seem to be any exceptions thrown, and neither the Error event nor the Shutdown event in Global.aspx are triggered when this happens. Instead, the Application_Start event is suddenly triggered and everything is reset to its initial state.
I read that changing certain files or changing files in critical directories would cause this to happen, but checking the modification date of each file when this occurs shows that not a single file in the application folder has been modified.
I have run the ANTS Memory Profiler to see if there are any memory leaks or other memory related issues that could lay ground to the issue, but memory usage seems completely stable, and never reaches any dramatic levels. At most the memory usage was at about 200 MB, where the CLR and ANTS itself stood for half of the usage. Either way, the issue seems to happen irregardless of the level of memory usage at the specific time.
I am deploying the application to a remote server. I do not have access to the server or any IIS configurations, so there is no way for me to actually adjust or monitor anything myself, although I can of course contact the people running the servers to help me do this. The restarts happen both when I run the application on my local IIS Express and on the remote server, but it does however seem to restart more often on the remote server.
I've added the contents of the Web.config file below. It's located in the root directory.
<configuration>
<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;url=~/VTT/Charts/;"/>
<add key="aspnet:MaxHttpCollectionKeys" value="100000"/>
</appSettings>
<connectionStrings>
<add name="DBConnString" providerName="System.Data.SqlClient"
connectionString="Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=DBC;Connection Timeout=120;Integrated Security=true;Trusted_Connection=true;"/>
</connectionStrings>
<system.web>
<httpHandlers>
<add path="ChartImg.axd" verb="GET,HEAD,POST" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
validate="false" />
</httpHandlers>
<sessionState mode="StateServer" stateConnectionString="tcpip=localhost:42424" cookieless="false" timeout="60"></sessionState>
<compilation debug="true" optimizeCompilations="false" targetFramework="4.5">
<assemblies>
<add assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
<customErrors mode="Off"></customErrors>
<httpRuntime targetFramework="4.5.1" executionTimeout="3600" maxRequestLength="10240"/>
<globalization culture="" uiCulture=""/>
<authentication mode="Windows">
<forms loginUrl="Default.aspx" defaultUrl="Default.aspx" name="adAuthCookie" timeout="60" path="/"/>
</authentication>
<authorization>
<deny users="?"/>
<allow users="*"/>
</authorization>
<pages maintainScrollPositionOnPostBack="true">
<controls>
<add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting"
assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls>
</pages>
</system.web>
<system.webServer>
<defaultDocument enabled="true">
<files>
<clear />
<add value="Default.aspx" />
</files>
</defaultDocument>
<caching>
<profiles>
<add extension=".ico" policy="CacheUntilChange" kernelCachePolicy="CacheUntilChange" />
</profiles>
</caching>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="ChartImageHandler" />
<add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD,POST"
path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<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>
</assemblyBinding>
</runtime>
</configuration>
And the Web.Release.config transformation file. (I switched out the connection string parameters for obvious reasons; they are all in order.)
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="DBConnString"
connectionString="Data Source=<server>;Initial Catalog=<cat>;User ID=<userid>;Password=<password>"
xdt:Transform="Replace" xdt:Locator="Match(name)" />
</connectionStrings>
<system.web>
<compilation debug="false" optimizeCompilations="true" xdt:Transform="SetAttributes(debug,optimizeCompilations)" />
</system.web>
</configuration>
Currently this issue is completely ruining my work, and my customer is extremely unhappy with constantly losing work due to application restarts. I'm at a complete loss on what to do. Any suggestions?

Related

running a .NET Framework 3.5-based application in .NET Framework 4 getting HTTP Error 500.19 - Internal Server Error

I have assigned a task to debug some issue for a previously build project. When I am running the project in Visual Studio 13 I got below --
Emphasis on this line--
this error is because you are running a .NET Framework 3.5-based
application in .NET Framework 4
I go through this articles--
.net 3.5 application on .net 4.0 runtime
https://learn.microsoft.com/en-us/dotnet/framework/migration-guide/version-compatibility
https://learn.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-configure-an-app-to-support-net-framework-4-or-4-5
Problem with .Net Framework 3.5 applications running in .Net Framework 4
I placed below code in my webconfig configuration section --
<startup>
<supportedRuntime version="v4.0" />
<supportedRuntime version="v2.0.50727" />
</startup>
But nothing changed. According to this article --
https://learn.microsoft.com/en-us/dotnet/framework/install/dotnet-35-windows-10
I enabled .net framework 3.5 in control panel. Still no hope with the same error. Can anyone suggest me how can I get rid of this error or start the project without any problem?
My Web Config is as below:
<?xml version="1.0"?>
<!--
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 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<connectionStrings>
<!--conectionstring is here-->
</connectionStrings>
<startup>
<supportedRuntime version="v4.0"/>
<supportedRuntime version="v2.0.50727"/>
</startup>
<appSettings>
<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>
<!--
For a description of web.config changes for .NET 4.5 see http://go.microsoft.com/fwlink/?LinkId=235367.
The following attributes can be set on the <httpRuntime> tag.
<system.Web>
<httpRuntime targetFramework="4.5" />
</system.Web>
-->
<system.web>
<!--<httpRuntime executionTimeout="5000"/>-->
<httpRuntime maxRequestLength="12288"/>
<customErrors mode="Off"/>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<authentication mode="None"/>
<pages controlRenderingCompatibilityVersion="4.0">
<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>
<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>
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection"/>
</providers>
</sessionState>
</system.web>
<system.webServer>
<!-- For ModSecurity-->
<validation validateIntegratedModeConfiguration="false"/>
<ModSecurity enabled="false" configFile="C:\inetpub\wwwroot\owasp_crs\modsecurity.conf"/>
<!-- For Videos
<staticContent>
<mimeMap fileExtension=".mp4" mimeType="video/mp4"/>
<mimeMap fileExtension=".m4v" mimeType="video/m4v"/>
</staticContent>-->
<!--<validation validateIntegratedModeConfiguration="false" />-->
<modules runAllManagedModulesForAllRequests="true"/>
<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>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30AD4FE6B2A6AEED" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
</dependentAssembly>
<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>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
</entityFramework>
</configuration>
After monitoring the web.config file contents, it was found that following line of configuration was causing the error:
<ModSecurity enabled="false" configFile="C:\inetpub\wwwroot\owasp_crs\modsecurity.conf"/>
After commenting out that line of code, the error was fixed.
The error message states that the configuration data is invalid which might have to do with updates to .NET 4.0 as stated on .NET Framework 4 migration issues section of the Migration Guide to the .NET Framework 4.7, 4.6, and 4.5:
Configuration files The root configuration files (the machine.config
file and the root Web.config file) for the .NET Framework and ASP.NET
4 have been updated to include most of the boilerplate configuration
information that was found in the application Web.config files in
ASP.NET 3.5. Because of the complexity of the managed IIS 7 and IIS
7.5 configuration systems, running ASP.NET 3.5 applications under ASP.NET 4 and under IIS 7 and IIS 7.5 can result in either ASP.NET
errors or IIS errors. Upgrade ASP.NET 3.5 applications to ASP.NET 4 by
using the project upgrade tools in Visual Studio 2010. Visual Studio
2010 automatically modifies the ASP.NET 3.5 application's Web.config
file to contain the appropriate settings for ASP.NET 4.
However, you can run ASP.NET 3.5 applications using the .NET Framework
4 without recompilation. In that case, you might have to manually
modify the application's Web.config file before you run the
application under the .NET Framework 4 and under IIS 7 or IIS 7.5. The
specific change you must make depends on the combination of software
you are working with, including Service Pack (SP) releases. For
information about the possible software combinations that are affected
by this change and how to resolve problems with specific combinations,
see the section "Configuration Errors Related to New ASP.NET 4 Root
Configuration" in the document ASP.NET 4 Breaking Changes on the
ASP.NET Web site.
ASP.NET 4 Breaking Changes states two sources of errors:
incorrect merger of machine.config and Web.config
configuration comparison fails due to version numbers not matching
Another option might be to change the order of the framework specification as it will use them in the preferred order from top to bottom as stated in Version Compatibility in the .NET Framework:
So perhaps this will work as well:
<startup>
<supportedRuntime version="v2.0.50727" />
<supportedRuntime version="v4.0" />
</startup>

Migrating Web Application from Windows Server 2008 to Windows Sever 2016

I am trying to solve a problem for one of my professors at school. He has a C# web project that he is trying to move from a computer running Windows Server 2008 to a newer machine running Windows Server 2016. It is being served with IIS and the students access the application by navigating to the computer's IP address from their own computers.
On the old computer, he simply copied the project folder into C:\inetpub\wwwroot and the application just runs when he navigates to localhost or to his IP address from another computer. However when he copies the project folder into C:\inetpub\wwwroot, the project does not run. Instead,
this is the screen he gets. If you click on the 'autograder' folder (which is the project folder he is trying to host), this HTTP error occurs. The web.config file is located here - C:\inetpub\wwwroot\autograder\Bin\WebApplication1\WebApplication1\web.config
After looking around online for solutions, I have made sure that the wwwroot folder has the required permissions (Web.Config - Cannot read configuration file due to insufficient permissions), but I am not sure why the error says it cannot read the configuration file, nor what is different about Windows Server 2016 that is preventing the project from just running like it did on Windows Server 2008.
Here is the web.config file:
<?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 -->
<!-- add System.Data.Entity.Infrastructure.SqlConnectionFactory -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-WebApplication1-20140618141327;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-WebApplication1-20140618141327.mdf" />
</connectionStrings>
<system.web>
<compilation debug="true" defaultLanguage="c#" targetFramework="4.0" />
<httpRuntime targetFramework="4.0" />
<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="InProc" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
</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>
</assemblyBinding>
</runtime>
<system.webServer>
<rewrite>
<rewriteMaps>
<rewriteMap name="start">
</rewriteMap>
</rewriteMaps>
</rewrite>
<defaultDocument>
<files>
<add value="Student.aspx" />
<add value="student" />
</files>
</defaultDocument>
</system.webServer>
</configuration>
I am new to Windows Server, IIS, and web hosting on Windows in general, so I would greatly appreciate any information on why this error is occurring or what changes I may have to make the project to get it to run on Windows Server 2016.
It turns out that the web.config file itself was the problem. I reset the contents of the web.config file and I was able to navigate to the application's home page. After piecing the web.config file back together, I found one set of tags that it didn't like, and that what was why it couldn't read the configuration file properly.

The underlying provider failed on Open

I'm using EntityFramework with Windows Azure platform. It works so well in LOCAL mode, but when I'm trying to run my Silverlight application on Web. I get an error:
The underlying provider failed on Open.
<configuration>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="DomainServiceModule" preCondition="managedHandler" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<add key="ValidationSettings:UnobtrusiveValidationMode" value="WebForms" />
</appSettings>
<system.web>
<httpModules>
<add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</httpModules>
<customErrors mode="Off" />
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
<httpRuntime requestValidationMode="4.5" targetFramework="4.5" encoderType="System.Web.Security.AntiXss.AntiXssEncoder, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<pages controlRenderingCompatibilityVersion="4.5" />
<machineKey compatibilityMode="Framework45" />
</system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<connectionStrings>
<add name="DatabaseEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string="data source=lnqg2ulkjr.database.windows.net;initial catalog=BuilderDatabase;persist security info=True;user id=XXXXX;password=XXXXX;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
I was checking that this is a problem in the connection string with Integrated Security but in my case I don't have that property. What could be the error?
This error is from Entity - it has little to do with Silverlight. It happens when one of two things happen:
Entity tries to log in to the database you've pointed it to, and is denied permission/can't find the server/can't find the instance/has some other connection error
Entity successfully logs in, but can't find the data model it recognizes
The second should be very simple to check since you have a working local. If the data model on your local is the same as the data model in your 'production' environment, then that part is taken care of. If you have tables that are different, you could have some issues. This is doubly true if they are missing columns that you've coded in to Entity's data model. Entity will tolerate extra columns and extra tables in many cases, though this changes a lot based on the situation, so YMMV. However, if Entity expects something to be there and it's not, it'll crash with a quickness every time.
My larger suspicion would be that rather awesome connection string you have there. You should be able to check the InnerException on what you're getting to see the specific gripe that the database server is raising. If it isn't, I would rip that out into a console application and attempt to connect with a plain jane SqlConnection doing a simple Select count(Id) from dbo.SmallTable. This will allow you to isolate the connection problems and deal with them in a nice, restricted environment. After you've sorted through the connection issues, you can paste your connection string - now hopefully less confusing - back in and move on.

Getting Security Exception SQLCE 4, Code First CTP 5 & Shared Hosting

I've been trying to setup a webpage with MVC3 Razor, SQLCE 4 and Code First, the last two downloaded from Nuget, so it is EF Code First CTP5.
I've had a lot of trouble, but I manage to move forward by following this answer
However now I am getting this 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.
I thought it should work without full trust so I don't know what is wrong now.
I am using GoDaddy shared hosting with .Net 4 and IIS7
What could be the issue?
EDIT:
I haven't modified the web.config, except for setting custom errors = false to be able to see the exceptions, otherwise I have the webconfig that was generated by using Nuget to get and configure SQLCE and Code first
This is how it is:
<?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>
<appSettings>
<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" />
</assemblies>
</compilation>
<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>
<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>
It seems to be a bug with CTP5 that will be fixed in final release.
http://connect.microsoft.com/VisualStudio/feedback/details/641462/ef-code-first-issue-with-medium-trust
Hmmm as I said in the first comment on the question, it is an error with Code First CTP5, which uses full trust instead of medium trust. Source

Permission Denied error when uploading files in FCKEditor

I recently moved my asp.net appliaction from windows 2003 / IIS 6 to windows IIS7.
No other changes, but now the file upload for the fckeditor doesn't work anymore.
Anyone know the obvious mistake I made here. :)
Thanks
The most likely problem is that the permissions need to be updated on the target folder. Check to make sure IUSR has create / write permissions to the upload directory.
Maybe this will help.
I couldn't get it to work either. I had all the permissions set. By debugging, I found out that the frmupload.html did not have execute access on the isapi.dll.
In IIS 7.0 I went to the web site on the left side and highlighted it. Then on the right pane, I clicked on handler mappings. I noticed at the top that isapi and cgi were disabled at the top.
I looked below and saw all the enabled handlers. I also noticed that there was not one for *.html but there was ones for *. Anyways, I right clicked anywhere in the lower pane where the enabled handlers are and I got a short cut menu. EDIT FEATURE PERMISSIONS is the option you want to click on. Then you will see checkboxes for read, script, and execute. I notice execute was not checked so I checked it.
Now the ISAPI and CGI became enabled in the list.
I tried uploading with FCKeditor and it worked. Just make sure your uploading the right file type to the right area or you might get invalid file or invalid file type message.
HOWEVER, i noticed I keep getting a new error. SYS is undefined error message on my web pages. Its a javascript error that usually happens when it can't find something. There are tons of reasons why you might get this error message if you google for it. In this case it was because I used Vista IIS7.0 to enable ISAPI with execute permissions. It went into my config file an made the correct setting change for enabling execute permission, however it erased all my handler setting!!!!
I took a backup copy of my webconfig and manually readded the settings. I think maybe its better to manually edit the webconfig file instead of letting IIS7 do it because it will do it but it might erase some of your settings.
Here is part of my webconfig file on VISTA IIS7 web server, before and after:
WebConfig BEFORE: enabling execute on cgi and isapi in VISTA IIS 7.0 web.config
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<remove name="ScriptModule"/>
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<remove name="ScriptHandlerFactory"/>
<remove name="ScriptHandlerFactoryAppServices"/>
<remove name="ScriptResource"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
AFTER: notice the
is added and all my handlers disappear. I just readded them and it worked.
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<remove name="ScriptModule" />
<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</modules>
<handlers accessPolicy="Read, Execute, Script">
</handlers>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
I am on a development machine VISTA so I didn't consider any security issues for opening up Execute. Hope this helps.
Like Sohnee says its most likly permissions, also make sure the 'uploads' folder actually exists in your 'public' folder (I'm not sure where this is in ASP).
Make sure that asp.net and iisuser_machinename user will have rights.

Categories