Migrating Web Application from Windows Server 2008 to Windows Sever 2016 - c#

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.

Related

Error: 26 - Error Locating Server/Instance Specified after hosting to a web server

I developed website using Asp.Net MVC C#, and everything works fine locally on my pc in Visual Studio. After hosting the website to the server I got Error: 26 - Error Locating Server/Instance Specified. The error shows up when I try to login to the website, after I press the login button.
I think the problem is with automatically created authentication database ASPNETDB.mdf in App_Data folder and the connection string to that database.
I was searching and trying different already published solutions before but I still can't solve the error.I tried different solutions to solve that in web.config, but unsucsessfully.
The solution I am looking is somewhere in configuring my ASP.NET Identity membership system, which works great locally on my pc and not after the upload.
I already have one database with one connection string to that database (BicycleWorldShop2). Should I publish ASPNETDB.mdf as a second database and add a second connection string in web.config file? How should I configure membership correctly?
This is the code of my 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=301880
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
<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.6.1" />
<httpRuntime targetFramework="4.6.1" />
<globalization culture="en-IN" />
<authentication mode="Forms">
<forms loginUrl="~/Accounts/LogOn" timeout="2880" />
</authentication>
<customErrors mode="Off" />
<membership>
<providers>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
</providers>
</membership>
<profile>
<providers>
<add name="AspNetSqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</profile>
<roleManager enabled="true">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" connectionStringName="LocalSqlServer" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add name="AspNetWindowsTokenRoleProvider" applicationName="/" type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</roleManager>
</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-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-5.2.4.0" newVersion="5.2.4.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
<connectionStrings>
<add name="BicycleWorldShop2" connectionString="Data Source=WW-PC\SqlExpress;Initial Catalog=BicycleWorldShop;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
What should I change in my code?
Does anyone how to solve this?
Please, for any help, I waste a lot of time in trying to solve this error!
The error:
I suggest to backup ASPNETDB.mdf and restore as a separate database on the hosting server. Then create second connectionstring under <connectionStrings> web.config section.
Lastly, update the connectionstringName property on membership, profile and roleManager providers.
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="SecondConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
Alternate Approach for adding ASPNETDB Object to same database
On your computer, type %WINDIR%\Microsoft.Net\Framework\ in run command and then go to v4.0... folder. In this folder, you will find T-SQL script files for creating Membership, Profile and Role schema. You will require to execute the scripts on your hosting provider database.
You will need to first execute the InstallCommon.sql for creating the common tables. Then you execute the following scripts.
InstallMembership.sql
InstallProfile.SQL
InstallRoles.sql
Note: All above mentioned scripts will assume that you have database named aspnetdb so you will require to open each sql file in text editor and then change the following lines of code to match your database name:
SET #dbname = N'aspnetdb'
USE [aspnetdb]
P.S
Do you really need AspNetWindowsTokenRoleProvider? Also, add <clear/> in membership and profile providers section

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>

How to deploy ASP.NET website with SQL Server database (membership enabled) in Godaddy using VS2013

I know this question is already answered but none solve my problem, I maybe having certain unknown issue. So I am again asking this question. Please help…. thanks in advance.
I am using Visual Studio 2013 update 3. I have developed an ASP.NET web application with membership enabled that uses the LocalDb provided by VS2013. I have published the website to GODADDY web server but I am not able to deploy the database. Without the database my application is working fine. I have created my SQL Server database in the GODADDY server. I am using the Build -> Publish option available in VS2013.
My web.config file is as
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="entityFramework"
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<connectionStrings>
<add name="DefaultConnection"
connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-WebTest-20150416011010.mdf;Initial Catalog=aspnet-WebTest-20150416011010;Integrated Security=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<authentication mode="None"/>
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5"/>
<customErrors mode="Off"/>
<trust level="Full"/>
<pages>
<namespaces>
<add namespace="System.Web.Optimization"/>
<add namespace="Microsoft.AspNet.Identity"/>
</namespaces>
<controls>
<add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt"/>
</controls>
</pages>
<membership>
<providers>
<clear/>
</providers>
</membership>
<profile>
<providers>
<clear/>
</providers>
</profile>
<roleManager>
<providers>
<clear/>
</providers>
</roleManager>
<sessionState mode="InProc" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection"/>
</providers>
</sessionState>
</system.web>
<system.webServer>
<httpErrors errorMode="Detailed"/>
<asp scriptErrorSentToBrowser="true"/>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089"/>
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb"/>
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>
</entityFramework>
</configuration>
My web.Release.config file as
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<connectionStrings>
<add name="DefaultConnection"
connectionString="Data Source=xxx.xxx.xxx.xxx; Initial Catalog=mydatabase; User ID=username; Password=password"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
</configuration>
Finally did it here it is
Before uploading do the following:
Goto Models open IdentityModels.cs and change the DefaultConnection to LocalSqlServer
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("LocalSqlServer", throwIfV1Schema: false)
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
In your web.config after uploading change this
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source= (LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-WebTest-20150416011010.mdf;Initial Catalog=aspnet-WebTest-20150416011010;Integrated Security=True"
providerName="System.Data.SqlClient"/>
to
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Data Source=111.111.111.111; Initial Catalog=myDB; User ID=username; Password=password" providerName="System.Data.SqlClient"/>
</connectionStrings>
and
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
</providers>
to
<providers>
<add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="LocalSqlServer" />
</providers>
Now goto your godaddy account and open Websites & Domains ---> ASP.NET Settings and add the LocalSqlServer connection string there if not added.
The connection string must be same as it is in the web.config file
For the database part you need to execute the script manually on the server through your database account in godaddy
The easiest way that recent versions of membership are deployed is by Code First migrations.
i.e. Provided that the Sql connection credentials have DBO access to your Godaddy database, the tables will be created as soon as membership functionality is required when you access it via your website.
If the connection doesn't have DBO access, an alternative way would be to Script the DDL to a .SQL file) for the the AspNet* membership tables from your local database and then run the same script on your Godaddy database using SSMS with a login which does have DBO access. You just need the following tables:
AspNetRoles
AspNetUserClaims
AspNetUserLogins
AspNetUserRoles
AspNetUsers

could not load file or assembly HtmAgilityPack verion 1.4.6.0

Ok, i have tried EVERYTHING mentioned on the internet. I have made most of my project in VS 2013 Express for Web. Since it doesn't support Crystal Reports, i reverted to VS2012 Ultimate. It opened the solution just fine and is working as well. The trouble i am having is when i try to add report, it goes past the Naming part, when it is about to load the report page it gives me the following error: ErrorLink.
My Toolkit was working fine on VS2013.
Toolkit version: 7.1213
AjaxMin: 4.97
HtmlAglilityPack: 1.4.9
I am giving my web.config file here:
<?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 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-SMC-20141224085758.mdf;Initial Catalog=aspnet-SMC-20141224085758;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="masterConnectionString" connectionString="Data Source=sana\sqlexpress;Initial Catalog=master;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="SMCConnectionString" connectionString="Data Source=sana\sqlexpress;Initial Catalog=SMC;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None"></add>
</appSettings>
<system.web>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<pages>
<namespaces>
<add namespace="System.Web.Optimization" />
<add namespace="Microsoft.AspNet.Identity" />
</namespaces>
<controls>
<add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
</controls>
</pages>
<membership>
<providers>
<!--
ASP.NET Membership is disabled in this template. Please visit the following link http://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template
-->
<clear />
</providers>
</membership>
<profile>
<providers>
<!--
ASP.NET Membership Profile is disabled in this template. Please visit the following link http://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template
-->
<clear />
</providers>
</profile>
<roleManager>
<!--
ASP.NET Membership Role is disabled in this template. Please visit the following link http://go.microsoft.com/fwlink/?LinkId=301889 to learn about the ASP.NET Membership support in this template
-->
<providers>
<clear />
</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>
<system.webServer>
<modules>
<remove name="FormsAuthenticationModule" />
</modules>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="WebGrease" culture="neutral" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.0.4" newVersion="2.1.0.4" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="HtmlAgilityPack" publicKeyToken="bd319b19eaf3b43a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.4.9.0" newVersion="1.4.9.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="HtmlAgilityPack" publicKeyToken="bd319b19eaf3b43a" culture="neutral" />
<bindingRedirect oldVersion="1.4.5.0-1.4.6.0" newVersion="1.4.6.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
I rebuilt the solution, cleaned it. I don't know what else to do. Any kind of help will be deeply appreciated.
Error Message:
Could not load file or assembly 'HtmlAgilityPack, Version=1.4.6.0,
Culture=neutral, PublicKeyToken=bd319b19eaf3b43a' or one of its
dependencies. The system cannot find the file specified.
I guess the error is with the version of assembly.
You specify that you work with follow :
HtmlAglilityPack: 1.4.9.0
In your code you have following
<assemblyIdentity name="HtmlAgilityPack" publicKeyToken="bd319b19eaf3b43a" culture="neutral" />
<bindingRedirect oldVersion="1.4.5.0-1.4.6.0" newVersion="1.4.6.0" />
I believe it shouldn't be there since you are using the newer version 1.4.9.0 and you already have that reference. (Which I miss to note on my first try to answer)
<dependentAssembly>
<assemblyIdentity name="HtmlAgilityPack" publicKeyToken="bd319b19eaf3b43a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.4.9.0" newVersion="1.4.9.0" />
</dependentAssembly>
Try this !!
1) Just right click on your Solution
2) Search For AjaxControlToolkit online
3) click on install
4) Restart Visual Studio
5)Build & Run
All The Best
ok, i did alot of searching and thanks to #Caleb and other person for being with me through it all. i uninstalled and reinstalled the different version of CR. It brought up some COM error about some object model lib. I removed the reference and tada.. it's working fine now.
And DO NOT forget to do this:
`When using ADO.NET with the Microsoft .NET Framework
4.0 (and above), the following setting must be added to the application’s configuration file:
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"/>
</startup>
</configuration>`
Hope this helps.
This problem can be arise due to the mismatch of the following dlls included in the project.Either any of the dll/package is missing or not the correct version, so either install or update that package:
AjaxControlToolkit
AjaxMin
HtmlAgilityPack
Tools -> Library Package Manager -> Package Manger Console
PM> install-package [name of the package with correct version]
Example: PM> Install-Package HtmlAgilityPack -Version 1.4.6
Could not load file or assembly 'HtmlAgilityPack, Version=1.4.6.0,
Culture=neutral, PublicKeyToken=bd319b19eaf3b43a' or one of its
dependencies. The system cannot find the file specified
I tried clearing all the temporary files from Temp folder. Just type %Temp% and delete all the files from that folder.
Then cheers my problem was solved.
Note: I tried the following but did not worked:
(i) Rebuilding, restarting, cleaning the solution + projects.
(ii) Referencing with its dll again.
(iii) clearing the data from the path C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files.
(iv) Downloading the missing packages.

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

Categories