SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Guru pinch's Avatar
    Join Date
    Mar 2005
    Posts
    686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Errors Moving Code to Production

    I'm having some strange issues trying to move an application from local machine to a production server. I'm not renting space, we actually house the servers ourselves. Locally, I'm using a database in my AppData directory (complete /w Membership schema), but upon launch am moving the database to a different server. I change my ConnectionStrings accordingly, but still regularly get this error. Some pages produce this error intermittently, other pages produce this error every time.

    The error is as follows:

    A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    SQLExpress database file auto-creation error:


    The connection string specifies a local Sql Server Express instance using a database location within the applications App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The following configuration requirements are necessary to successfully check for existence of the application services database and automatically create the application services database:


    If the applications App_Data directory does not already exist, the web server account must have read and write access to the applications directory. This is necessary because the web server account will automatically create the App_Data directory if it does not already exist.
    If the applications App_Data directory already exists, the web server account only requires read and write access to the applications App_Data directory. This is necessary because the web server account will attempt to verify that the Sql Server Express database already exists within the applications App_Data directory. Revoking read access on the App_Data directory from the web server account will prevent the provider from correctly determining if the Sql Server Express database already exists. This will cause an error when the provider attempts to create a duplicate of an already existing database. Write access is required because the web server accounts credentials are used when creating the new database.
    Sql Server Express must be installed on the machine.
    The process identity for the web server account must have a local user profile. See the readme document for details on how to create a local user profile for both machine and domain accounts.
    I'm absolutely sure that there are no references to the 'LocalSqlServer' connection string in my web.config, so I'm not sure why it thinks I'm referencing code in the AppData directory.

    Here is my web.config:

    <?xml version="1.0"?>
    <!--
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\v2.x\Config
    -->
    <configuration>
    <configSections>
    <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
    <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    </sectionGroup>
    </sectionGroup>
    </sectionGroup>
    <section name="epas" type="USMC.EPAS.EpasConfigSection"/>
    </configSections>
    <!-- Custom Config Section -->
    <epas defaultConnectionStringName="EPASDEVUserString" defaultCacheDuration="300">
    <personnel providerType="USMC.EPAS.DAL.SqlClient.SqlPersonnelProvider" enableCaching="true" cacheDuration="600"/>
    </epas>
    <appSettings/>
    <connectionStrings>
    <add name="EPASDEVUserString" connectionString="Data Source=servername.xxx;Initial Catalog=EPAS;User ID=MyUser;Password=1234556" providerName="System.Data.SqlClient"/>
    </connectionStrings>
    <system.web>
    <!--
    Set compilation debug="true" to insert debugging
    symbols into the compiled page. Because this
    affects performance, set this value to true only
    during development.
    -->
    <compilation debug="true">
    <assemblies>
    <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies>
    </compilation>
    <!--
    The <authentication> section enables configuration
    of the security authentication mode used by
    ASP.NET to identify an incoming user.
    -->

    <!--Roles-->
    <roleManager enabled="true"/>
    <!--Authentication-->
    <authentication mode="Forms">
    <forms name="EPASFORMAUTH" defaultUrl="~/About.aspx" loginUrl="~/Register.aspx" slidingExpiration="true" timeout="20"/>
    </authentication>
    <!--Session-->
    <sessionState timeout="10"/>

    <!--Sitemap-->
    <siteMap defaultProvider="EPAS_SiteMapProvider" enabled="true">
    <providers>
    <add name="EPAS_SiteMapProvider" type="System.Web.XmlSiteMapProvider" siteMapFile="web.sitemap" securityTrimmingEnabled="true"/>
    </providers>
    </siteMap>



    <!--The <customErrors> section enables configuration
    of what to do if/when an unhandled error occurs
    during the execution of a request. Specifically,
    it enables developers to configure html error pages
    to be displayed in place of a error stack trace.-->

    <customErrors mode="Off">
    <error statusCode="403" redirect="NoAccess.htm" />
    <error statusCode="404" redirect="FileNotFound.htm" />
    </customErrors>

    <pages theme="Theme1">
    <controls>
    <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </controls>
    </pages>
    <httpHandlers>
    <remove verb="*" path="*.asmx"/>
    <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
    </httpHandlers>
    <httpModules>
    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </httpModules>
    </system.web>


    <location path="~/Register.aspx">
    <system.web>
    <authorization>
    <deny users="*"/>
    <allow users="?"/>
    </authorization>
    </system.web>
    </location>

    <system.codedom>
    <compilers>
    <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <providerOption name="CompilerVersion" value="v3.5"/>
    <providerOption name="WarnAsError" value="false"/>
    </compiler>
    <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
    <providerOption name="CompilerVersion" value="v3.5"/>
    <providerOption name="OptionInfer" value="true"/>
    <providerOption name="WarnAsError" value="false"/>
    </compiler>
    </compilers>
    </system.codedom>
    <!--
    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>
    </configuration>

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2009
    Location
    England
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Luckly I've never had your problem, thank god - because we all hate intermittent errors.

    Have you set read/write access for IUSR_COMPUTERNAME to the app_data folder ?

    As a matter of course I reset all access rights, every time I update my production server, due to random access error from ASP. NET (Actually it was a solution given to me, for a badly behavouring Virtual Server, but once a practice starts, you just don't stop - just in case)

  3. #3
    SitePoint Guru pinch's Avatar
    Join Date
    Mar 2005
    Posts
    686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SirKilljoy View Post
    Luckly I've never had your problem, thank god - because we all hate intermittent errors.

    Have you set read/write access for IUSR_COMPUTERNAME to the app_data folder ?

    As a matter of course I reset all access rights, every time I update my production server, due to random access error from ASP. NET (Actually it was a solution given to me, for a badly behavouring Virtual Server, but once a practice starts, you just don't stop - just in case)
    Well, my point is that the App_Data directory should be irrlevant because my ConnectionString points to an actual server. The fact that is it trying to access/modify my App_Data directory seems to be the source of my problem.

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2009
    Location
    England
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I apologise, your quite right, I saw an error and tried to fix it instead of looking for an underlying cause.

    I've had a look through your Web.config, and I'm of little help.

    My only suggest, which might not be relevant, is to try and replicate the production server error in your development environment by A) Use the actual server SQL instead of SQL Server Express and B) Stop write access to your login user to app_data (If that is even possible).

    Good luck

  5. #5
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This page help you out: http://www.connectionstrings.com/sql-server-2008#1

    Sounds like your using Sql Express, you will find the required info about 1/4 of the way down.

  6. #6
    SitePoint Guru pinch's Avatar
    Join Date
    Mar 2005
    Posts
    686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dhtmlgod View Post
    This page help you out: http://www.connectionstrings.com/sql-server-2008#1

    Sounds like your using Sql Express, you will find the required info about 1/4 of the way down.
    Well, I'm was using Sql Express on my local machine, but am using SQL Server 2005 on the production box, so my connection string properly reflects this.

    Examining the error that I'm seeing, it appears that the application on the server is insisting on trying to create an ASPNETDB database in my App_Data directory (I'm guessing to create the necessary Membership schema). Initially I thought it was doing this because I did not create a <membership/> section in my web.config and point it to the database on my production server where the Membership tables already reside. However, after adding that tag I am still getting the error.

    <membership defaultProvider="EPASMembershipProvider" userIsOnlineTimeWindow="20">
    <providers>
    <clear/>
    <add name="EPASMembershipProvider" connectionStringName="EPASDEVUserString" applicationName="/"
    minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0"
    type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral"/>
    </providers>
    </membership>
    I decided to try to investigate further by running a local application but still pointing to the membership provider on the remote server. When I try to run the 'Web Site Administration Tool' locally under these conditions, I get the following error:

    There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.

    The following message may help in diagnosing the problem: Could not load file or assembly 'System.Web, Version=2.0.0.0, Culture=neutral' or one of its dependencies. The system cannot find the file specified. (D:\Brad\work\projects\epas\applications\EPAS\EPAS_Web\web.config line 72)
    I know that my role manager is enabled. Could it be that I am being denied access to the membership schema, so the system is then defaulting and trying to create a membership schema in my App_Data directory, where it promptly fails?

  7. #7
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,576
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Set the connectionstringname property in your membership providers or override the localsqlserver connection string in your connection strings. Should get you squared away.

    As for debugging that error, basically there are two general directions and it is pretty easy to figure out which one is which. If you get a long wait before the error, it means it can't find the SQL server for some reason. Quick error means you are hitting the sql server, but you can't login.

  8. #8
    SitePoint Guru pinch's Avatar
    Join Date
    Mar 2005
    Posts
    686
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by wwb_99 View Post
    Set the connectionstringname property in your membership providers or override the localsqlserver connection string in your connection strings. Should get you squared away.

    As for debugging that error, basically there are two general directions and it is pretty easy to figure out which one is which. If you get a long wait before the error, it means it can't find the SQL server for some reason. Quick error means you are hitting the sql server, but you can't login.
    Thanks for that. I did what you suggested and that got me much closer to the finish line. The ultimate problem I was facing was that for some reason it was choking on my 'type' property of my <membership> tag.

    type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral"
    I removed the bolded portion of the above field in the <membership> tag and everything sprung to life. I think I copied that field from a 2.0 application so maybe that version simply isn't available anymore? (I'm using VS2008 now)

    At any rate it looks like, after it choked on the type property (and because I was specifying the default SqlMembershipProvider), it decided to go ahead and try to create the membership schema in my App_Data directory. Permissions weren't allowing this to happen which is presumably why the error was getting thrown.

    After adding a <roleManager> tag and adding the proper ConnectionString to that as well, everything seems to be operational now.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •