Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 31st, 2010, 10:21 PM
Authorized User
 
Join Date: Sep 2009
Posts: 35
Thanks: 6
Thanked 1 Time in 1 Post
Default Having trouble Deploying to remote server

Hello,

I tried following the deployment instructions in the book to deploy a project I have been working on, but it seems like I am having some issues with it connecting to the DB that I have been using. Everything works perfectly locally but I have been trying to debug this on the server to no avail.

Here is the error:

Quote:
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)
I think I made every necessary change in the web.config, this is what it looks like:

Code:
<?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>
	</configSections>
	<appSettings/>
	<connectionStrings>
		<add name="STMConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\STM.mdf;Integrated Security=True;User Instance=True" 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.

            Visual Basic options:
            Set strict="true" to disallow all data type conversions 
            where data loss can occur. 
            Set explicit="true" to force declaration of all variables.
        -->
		<roleManager enabled="true" />
  <compilation debug="false">
			<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.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies>
		</compilation>
		<pages>
			<namespaces>
				<clear/>
				<add namespace="System"/>
				<add namespace="System.Collections"/>
				<add namespace="System.Collections.Generic"/>
				<add namespace="System.Collections.Specialized"/>
				<add namespace="System.Configuration"/>
				<add namespace="System.Text"/>
				<add namespace="System.Text.RegularExpressions"/>
				<add namespace="System.Linq"/>
				<add namespace="System.Xml.Linq"/>
				<add namespace="System.Web"/>
				<add namespace="System.Web.Caching"/>
				<add namespace="System.Web.SessionState"/>
				<add namespace="System.Web.Security"/>
				<add namespace="System.Web.Profile"/>
				<add namespace="System.Web.UI"/>
				<add namespace="System.Web.UI.WebControls"/>
				<add namespace="System.Web.UI.WebControls.WebParts"/>
				<add namespace="System.Web.UI.HtmlControls"/>
			</namespaces>
			<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>
		<!--
            The <authentication> section enables configuration 
            of the security authentication mode used by 
            ASP.NET to identify an incoming user. 
        -->
		<authentication mode="Forms" />
		<!--
            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">

		</customErrors>
		<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>
	<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>
  <system.net>
    <mailSettings>
      <smtp deliveryMethod="Network" from="[email protected]">
        <network host="smtp.gmail.com" port="587" userName="**********" password="********"/>
      </smtp>
    </mailSettings>
  </system.net>
	<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>
  <location path="Management">
    <system.web>
      <authorization>
        <allow roles="Admins"/>
        <deny users="*"/>
      </authorization>
    </system.web>
  </location>
  <location path="">
    <system.web>
      <authorization>
        <allow roles="Admins"/>
        <deny users="*"/>
      </authorization>
    </system.web>
  </location>
</configuration>
The server is setup for ASP.NET 3.5 with IIS7.0

Last edited by digink; June 1st, 2010 at 08:27 AM..
 
Old June 1st, 2010, 02:06 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi digink,
Quote:
Everything works perfectly locally but I have been trying to debug this on the server to no avail.
combined with
Quote:
<add name="STMConnectionString1" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\STM.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
makes me suspect that your deployment server does not have SQL Server Express installed, or at least not with the default instance name of SqlExpress.

Can you check the SQL Server installation and configuration on the deployment server?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 1st, 2010, 08:31 AM
Authorized User
 
Join Date: Sep 2009
Posts: 35
Thanks: 6
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by Imar View Post
Hi digink,
combined with
makes me suspect that your deployment server does not have SQL Server Express installed, or at least not with the default instance name of SqlExpress.

Can you check the SQL Server installation and configuration on the deployment server?

Imar
Imar,

This is my first time actually deploying an ASP.NET website in which I'm using a DB to store/display information. The server I have is set up for 2 DB setups of SQL Server 2005, even after my DB files are uploaded in the App_Data folder would I still have to go in here and manually set-up a DB and name it?

I'm sorry I read through the deployment chapter a few times and was still a little confused, not really a fault of the book as it is so different with all of the hosting companies out there.

Thanks!

p.s. I plan on posting a link to the site I developed using your book for a client. I previously had experience with VB.NET, SQL Server, and HTML/CSS but none with any kind of environment that allows for data-driven web pages other than some simple Javascript. With your book I was able to develop a very nice web-page using my previous skills and applying them with the knowledge presented in the book. It is surprising how simple everything was and how great it turned out! Anyways once I can get this deployed to the server properly I'll post the link so everyone can see what can be done with the knowledge presented in the book!
 
Old June 1st, 2010, 08:42 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
The server I have is set up for 2 DB setups of SQL Server 2005, even after my DB files are uploaded in the App_Data folder would I still have to go in here and manually set-up a DB and name it?
You need to talk to your host to answer that question. 9 out of 10, no 99 out of 100 hosting parties don't support SQL Express. Instead, they can restore database backups for you, or attach MDF filess or give you an on-line Control Panel to manage your own database. With that also comes a different connection string, not targetting the local .SqlExpress but a different SQL Server in their network. Your host should have documentation, FAQs or a support department that should be able to help you out becauses, as you said, each host has different rules and requirements.

Quote:
p.s. I plan on posting a link to the site I developed using your book for a client. I previously had experience with VB.NET, SQL Server, and HTML/CSS but none with any kind of environment that allows for data-driven web pages other than some simple Javascript. With your book I was able to develop a very nice web-page using my previous skills and applying them with the knowledge presented in the book. It is surprising how simple everything was and how great it turned out! Anyways once I can get this deployed to the server properly I'll post the link so everyone can see what can be done with the knowledge presented in the book!
Good to hear that! Looking forward to that link.... ;-)

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 1st, 2010, 09:17 AM
Authorized User
 
Join Date: Sep 2009
Posts: 35
Thanks: 6
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by Imar View Post
You need to talk to your host to answer that question. 9 out of 10, no 99 out of 100 hosting parties don't support SQL Express. Instead, they can restore database backups for you, or attach MDF filess or give you an on-line Control Panel to manage your own database. With that also comes a different connection string, not targetting the local .SqlExpress but a different SQL Server in their network. Your host should have documentation, FAQs or a support department that should be able to help you out becauses, as you said, each host has different rules and requirements.

Good to hear that! Looking forward to that link.... ;-)

Cheers,

Imar
Imar,

Quick question. Do you have any idea if even though the hosting I have to deal with only has SQL Server 2005 installed (not Express) if I'd still be able to create some SQL scripts to work with? I'm not sure if I'll be able to get them to put SQL Server Express on the hosting account for the client. The tech support for them is horrible so just want to check if you know if SQL Server is able to work with DB's set up for Express, I would think so but I'm not as experienced.
 
Old June 1st, 2010, 09:26 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

The .mdf file format is shared by all license types of SQL Server. That means you can take an .mdf file created with SQL Express and atach it to, say, SQL Server Standard, or the other way around. You can attach 2005 files to 2008, but not the other way around.

What's important though is that you need to attach the .mdf files to SQL Server; you can't use the AttachDbFilename parameter in the connection string as Express allows you to do. Attaching is something hosts typically need to do for you.

Note that besides attaching .mdf files, you might also be able to execute SQL files (created by the Publishing Wizard as explained in the book) or to restore a backup of SQL Server. Again, it all depends on your host.....

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 2nd, 2010, 03:38 PM
Authorized User
 
Join Date: Sep 2009
Posts: 35
Thanks: 6
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by Imar View Post
The .mdf file format is shared by all license types of SQL Server. That means you can take an .mdf file created with SQL Express and atach it to, say, SQL Server Standard, or the other way around. You can attach 2005 files to 2008, but not the other way around.

What's important though is that you need to attach the .mdf files to SQL Server; you can't use the AttachDbFilename parameter in the connection string as Express allows you to do. Attaching is something hosts typically need to do for you.

Note that besides attaching .mdf files, you might also be able to execute SQL files (created by the Publishing Wizard as explained in the book) or to restore a backup of SQL Server. Again, it all depends on your host.....

Imar
Imar,

I figured out I had to set a DB on the remote server, and I am in the process of uploading both my database, but I ran across something I'm not sure how to tackle.

As shown above, my website has an STMConnectionString1, but when I upload to the site they want me to change the datasource to what they have specified. Can I keep the actual name of the Connection string the same and just change the datasource?

Also it seems I have to merge both the ASPNET stuff (with the membership, users, etc) with my data DB, not sure if that will mess up the connection string.

Thanks
 
Old June 2nd, 2010, 05:47 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
As shown above, my website has an STMConnectionString1, but when I upload to the site they want me to change the datasource to what they have specified. Can I keep the actual name of the Connection string the same and just change the datasource?
Yes. That's the whole idea of the named connection string: you can change the connection string, while all your code referring to the name keeps working. In other words, they get a reference to the item in web.config based on its name and then use the item's connection string to access the database.

Quote:
Also it seems I have to merge both the ASPNET stuff (with the membership, users, etc) with my data DB, not sure if that will mess up the connection string.
It won't mess up the connection string. However, you need to modify the application services and have their connection string updated to point to your connection string STMConnectionString1, rather than their default of LocalSqlExpress. The book explains how to do this.

Hope this helps,

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 2nd, 2010, 06:28 PM
Authorized User
 
Join Date: Sep 2009
Posts: 35
Thanks: 6
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by Imar View Post
Yes. That's the whole idea of the named connection string: you can change the connection string, while all your code referring to the name keeps working. In other words, they get a reference to the item in web.config based on its name and then use the item's connection string to access the database.

It won't mess up the connection string. However, you need to modify the application services and have their connection string updated to point to your connection string STMConnectionString1, rather than their default of LocalSqlExpress. The book explains how to do this.

Hope this helps,

Cheers,

Imar
awesome, I'll reference the book.

Thanks!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble Deploying jluc311 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 8 March 30th, 2009 02:19 PM
deploying wroxapp in weblogic server veenaV BOOK: Professional Jakarta Struts 0 September 21st, 2006 12:53 AM
deploying crystal report in asp.net on remote serv rayeesf2002 Crystal Reports 1 March 24th, 2006 02:23 AM
VB Express and SQL server on remote server questio HoosierDaddy61 Visual Basic 2005 Basics 0 February 22nd, 2006 11:27 AM
connecting web server and remote db server via asp moreyt Classic ASP Databases 0 May 31st, 2005 12:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.