views:

426

answers:

2

I would appreciate opinions or suggestions.

For several years, I have had an html and javascript website that was housed on a shared Apache server hosted by Wild West. Recently I decided to migrate it to .NET 3.5 and put it on a shared Windows IIS7 server also hosted by Wild West. I rewrote all of the pages using Visual Studio 2008, added role management, a sitemap-controlled menu tree with role-based security trimming enabled, and secured directories. There are maybe a half dozen pages with a couple of secured directories that have, at this point, just one or two files in each. Simple site.

I used VS2008's ASP.NET Configuration tool to create users and roles that match all of the role names in the sitemap and confirmed the users, etc, are in the aspnet_ tables in the App_Data/ASPNETDB.MDF database. The site renders fine on local machine. The Login.aspx page allows the user to log in, the menu tree adjusts accordingly, the login status control adjusts accordingly, and the user is redirected appropriately… everything works as designed.

I took out the shared Windows hosting account with Wild West (formerly GoDaddy), exported the ASPNETDB tables and data to a .sql file and recreated them on the MS SQL server, edited the connection string in web.config to use the connection string supplied by Wild West, then used FileZilla to ftp/copy the files and folders to the Windows server. The .aspx pages will render with no problem but when I try to use any of the usernames and passwords to log in, a SQL exception is thrown. This is the pretty vague exception message:

An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Wild West’s tech support had me delete and recreate the database ensuring that remote connections are allowed and they verified the connection string information is correct but the exception is still thrown when trying to login. Now, here’s the strange part, I can hard code the connection information into the code-behind of a page and it will successfully connect to the database to extract information. So the database is reachable by the web server.

So, I began to wonder… is the problem because I simply copied the pages, code-behind files, and folders to the server instead of building them and then copying the compiled version to the server? HTML is very different from .NET and Apache servers are very different from IIS7. I had read somewhere that uncompiled sites copied to IIS7 would be compiled by the server on the first demand but maybe that isn’t true. The folder structure on the server does not include a BIN folder, which leads me to believe the server did not, in fact, build the site. Should I delete the files and folders off of there, build the site on local machine, and then copy the built version back to the server? Could this be what is causing the error message?

Thanks for any information you can give. Have a happy holiday season.

John

+2  A: 

I really doubt the problem you're seeing has anything to do with how you deployed your website. IIS will automatically compile the website on the first request if you have not already published it. You could always try publishing it and copying all of the libraries to the server, however I don't think this will solve the issue.

To me it sounds like an issue of the database server not being reachable from your web server.

Can you post the connection string you're using, without the username/password so we can look at?

RexM
+1  A: 

The problem has been fixed. It was a multi-part issue. The connection string section needed a element to wipe out anything inherited from the hosting company. The roles and membership sections weren't referencing the connectionstring in order to get their data. And then the login control wasn't finding the user name that should have been there so we added a Global.asax file that adds the user if not found. The entire problem and process has been posted at this link: asp.net forum post