关于复制与发布网站的问题

发布于 2024-07-10 05:33:34 字数 1318 浏览 11 评论 0原文

我将不胜感激的意见或建议。

多年来,我一直有一个 html 和 javascript 网站,该网站位于 Wild West 托管的共享 Apache 服务器上。 最近,我决定将其迁移到 .NET 3.5,并将其放在同样由 Wild West 托管的共享 Windows IIS7 服务器上。 我使用 Visual Studio 2008 重写了所有页面,添加了角色管理、站点地图控制的菜单树(启用了基于角色的安全修剪)以及安全目录。 可能有六个页面,其中有几个安全目录,此时每个目录中只有一两个文件。 简单的网站。

我使用VS2008的ASP.NET配置工具创建与站点地图中所有角色名称匹配的用户和角色,并确认用户等位于App_Data/ASPNETDB.MDF数据库的aspnet_表中。 该网站在本地计算机上呈现良好。 Login.aspx 页面允许用户登录,菜单树相应调整,登录状态控件相应调整,并且用户被适当重定向......一切都按设计进行。

我拿出与 Wild West(以前称为 GoDaddy)共享的 Windows 托管帐户,将 ASPNETDB 表和数据导出到 .sql 文件,并在 MS SQL 服务器上重新创建它们,编辑 web.config 中的连接字符串以使用提供的连接字符串由 Wild West 开发,然后使用 FileZilla 将文件和文件夹 ftp/复制到 Windows 服务器。 .aspx 页面将毫无问题地呈现,但当我尝试使用任何用户名和密码登录时,会引发 SQL 异常。 这是非常模糊的异常消息:

建立与服务器的连接时发生错误。 当连接到SQL Server 2005时,出现此故障的原因可能是SQL Server在默认设置下不允许远程连接。 (提供商:SQL 网络接口,错误:26 - 指定服务器/实例错误)

Wild West 的技术支持让我删除并重新创建数据库,确保允许远程连接,并且他们验证了连接字符串信息是否正确,但仍然引发异常当尝试登录时。 现在,这是奇怪的部分,我可以将连接信息硬编码到页面的代码隐藏中,它将成功连接到数据库以提取信息。 因此 Web 服务器可以访问数据库。

所以,我开始想……问题是因为我只是将页面、代码隐藏文件和文件夹复制到服务器,而不是构建它们,然后将编译的版本复制到服务器吗? HTML 与 .NET 有很大不同,Apache 服务器与 IIS7 有很大不同。 我曾在某处读到,复制到 IIS7 的未编译站点将由服务器在第一次请求时进行编译,但也许事实并非如此。 服务器上的文件夹结构不包含 BIN 文件夹,这使我相信服务器实际上并未构建该站点。 我应该删除那里的文件和文件夹,在本地计算机上构建站点,然后将构建的版本复制回服务器吗? 这可能是导致错误消息的原因吗?

感谢您提供的任何信息。 祝您假期愉快。

约翰

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

拍不死你 2024-07-17 05:33:34

我真的怀疑您所看到的问题与您部署网站的方式有关。 如果您尚未发布网站,IIS 将在第一次请求时自动编译该网站。 您始终可以尝试发布它并将所有库复制到服务器,但我认为这不能解决问题。

对我来说,这听起来像是无法从网络服务器访问数据库服务器的问题。

您可以发布您正在使用的连接字符串(不带用户名/密码)以便我们查看吗?

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?

栖迟 2024-07-17 05:33:34

问题已得到解决。 这是一个由多个部分组成的问题。 连接字符串部分需要一个元素来清除从托管公司继承的任何内容。 角色和成员资格部分没有引用连接字符串来获取其数据。 然后登录控件找不到应该存在的用户名,因此我们添加了一个 Global.asax 文件,如果找不到则添加用户。 整个问题和过程已发布在此链接中:asp.net 论坛帖子

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文