我刚刚购买了一台新的 Windows Server 2003 计算机,并且一直在尝试在其上安装 Nerddinner。 服务器已经有 .NET 3.5 SP1、ASP .NET MVC 等。
当我通过 FTP 将 Nerddinner 上传到主网页的子目录时,当我访问站点中除根目录和主页不显示地图。
例如,当我转到“关于”页面时,我收到以下 IIS 日志条目:
2009-08-13 17:56:10 128.200.123.118 GET /nerddinner/Home/About - 80 - 128.200.123.89 Mozilla/4.0+(兼容;+MSIE+8.0 >) 404 0 3
我非常困惑,因为这是从 Codeplex 新鲜下载并编译的 Nerddinner 副本。
如果它有帮助,这里是获取地图 JavaScript 失败尝试的日志条目(注意完全缺少“/nerddinner”):
2009-08-13 18:03:05 128.200.123.118 GET /Scripts/Map.js - 80 - 128.200.123.89 Mozilla/4.0+(兼容;+MSIE+8.0 >) 404 0 3
我有一种强烈的感觉,我应该能够在 asax.cs 文件中修复这个问题,但即使在前面附加“nerddinner/”之后,我也无法完全让它工作。
对正在发生的事情有什么想法吗?
编辑:我将其上传到网络文件夹的根目录,404 继续。
编辑2:感谢您的建议。 我按照说明进行操作,现在我没有收到 404 错误。 但是,还存在 2 个主要问题:
- 脚本和内容文件夹无法正确映射。 我对这些文件夹内的文件的所有引用都收到 404 错误。
-
我根本看不到晚餐。 我得到:
描述:处理服务此请求所需的配置文件期间发生错误。 请查看下面的具体错误详细信息并适当修改您的配置文件。
和一条红色线,上面写着 "
"。 除了 ConnectionStrings.config 在服务器上不存在之外,因此根据 VS,它不是一个重要文件,因此,我不知道错误指的是什么。
(快速搜索我的本地硬盘驱动器会发现一个 ConnectionStrings.config 文件,其中没有任何内容)
编辑 3:
现在,当我查看时,我认为我得到的相当于 SQL Server 404晚餐...
建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误。 服务器未找到或无法访问。 验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。 (提供程序:SQL 网络接口,错误:26 - 定位指定的服务器/实例时出错)
帮助其他人在 IIS6 上运行 ASP .NET MVC 的摘要,尤其是书呆子晚餐:
- IIS 6 可能会向您抛出大量 404因为它不明白文件不能有扩展名。 要解决此问题,请按照 菲尔·哈克的博客文章。
- ASP .NET MVC URL 重写并不神奇。 它仅重写通过代码传送的 URL。 对脚本、图像、数据库、直接链接(也称为 href 标签;不是动态生成的标签)等的引用不会根据应用程序的目录重新映射。 对于 Nerddinner 应用程序,浏览页面并在这些引用的引用前面添加“/nerddinner/”。 将“nerddinner”替换为您的子目录的名称。
- 获取数据库并将其附加到服务器上的 SQL Server(或 SQL Server Express)。 将网络用户添加到具有读/写角色的数据库中。
-
为您的设置填写正确的连接字符串。 就我而言,我通过 IP 地址引用服务器并使用 SQL Server 2005,因此我的连接字符串是:
I just got a new Windows Server 2003 machine and I've been trying to get Nerd Dinner onto it. The server already has .NET 3.5 SP1, ASP .NET MVC, etc.
When I upload Nerd Dinner via FTP to a subdirectory of the main webpage, I get a 404 when I go to any page in the site except for the root and the home page doesn't event show the map.
For example, when I go to the about page, I get the following IIS log entry:
2009-08-13 17:56:10 128.200.123.118 GET /nerddinner/Home/About - 80 - 128.200.123.89 Mozilla/4.0+(compatible;+MSIE+8.0<snip
>) 404 0 3
I'm extremely puzzled because this is a freshly downloaded and compiled copy of Nerd Dinner from Codeplex.
In case it helps, here's a log entry from the failed attempts to get the JavaScript for the map (note the complete lack of "/nerddinner"):
2009-08-13 18:03:05 128.200.123.118 GET /Scripts/Map.js - 80 - 128.200.123.89 Mozilla/4.0+(compatible;+MSIE+8.0<snip
>) 404 0 3
I have a strong feeling that I should be able to fix this inside the asax.cs file but I can't quite get it to work even after appending "nerddinner/" to the front.
Any ideas for what's happening?
Edit: I uploaded it to the root of the webfolder and the 404s continue.
Edit 2: Thanks for the suggestions. I followed the instructions and now I don't get 404s. However, there are 2 major problems left:
- The scripts and content folders don't map correctly. I get 404s on all references to the files inside those folders.
I can't view dinners at all. I get:
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
and a line in red that says "<connectionStrings configSource="ConnectionStrings.config" />
". Except that ConnectionStrings.config doesn't exist on the server, so it wasn't an important file according to VS, and thus, I have no idea what the error is referring to.
(a quick search of my local hard drive turns up a ConnectionStrings.config file with nothing in it)
Edit 3:
Now I think I'm getting the equivalent of a SQL Server 404 when I go to view dinners...
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)
Summary To Help Others Running ASP .NET MVC on IIS6, Especially Nerd Dinner:
- IIS 6 may throw piles of 404s at you because it doesn't understand that files can have no extensions. To solve that, follow the steps in Phil Haack's blog post.
- ASP .NET MVC URL rewriting is not magic. It only rewrites URLs that are piped through code. References to scripts, images, databases, direct links (aka a href tags; not the ones that are dynamically generated) etc. are not remapped based on the directory of your application. For the Nerd Dinner application, go through the pages and add "/nerddinner/" in front of references to these references. Substitute "nerddinner" with the name of your subdirectory.
- Take the database and attach it to SQL Server (or SQL Server Express) on your server. Add the Network User to the database with read/write roles.
-
Fill in the correct connection string for your setup. In my case, I was referring to the server by IP address and using SQL Server 2005 so my connection string is:
<add name="NerdDinnerConnectionString" connectionString="Data Source=128.200.123.118; Initial Catalog=NerdDinner; Integrated Security=SSPI" providerName="System.Data.SqlClient.SqlConnection"/>
发布评论
评论(2)
你在 IIS6 上运行它吗? 如果是的话,您将需要修补路由表以考虑 .ASPX 扩展名,这是 IIS6 或多或少需要的。
Phil Haack 有一个很好的演练解释了这个过程。 他还解释了无需 .ASPX 扩展名即可实现此目的的方法:
http://haacked. com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx
Are you running it on IIS6? If you are, you will need to patch the route table to take into account the .ASPX extension, which IIS6 more or less requires.
Phil Haack has a good walkthrough that explains this process. He also explains ways you can do it without the .ASPX extension:
http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx
在 ASP.NET MVC 文件中,不会像在 ASP.NET 中那样一对一地映射到 URL。 相反,路由表中的匹配会将 GET 或 POST 请求从浏览器转移到控制器之一中的控制器方法。 从那里,控制器决定(明确地或按照约定)要显示哪个视图。
ConnectionStrings.config 需要存在于服务器上,因为它在 web.config 中被引用。 它是一个包含文件,因此其中不一定包含任何内容。 但如果要引用它,则需要将其包含在服务器上,因此只需使用 FTP 程序将其复制到那里即可。
In ASP.NET MVC files do not map one for one to an URL, like they do in ASP.NET. Instead, a match in the routing table diverts a GET or POST request from the browser to a controller method in one of your controllers. From there, the controller decides (either explicitly or by convention) which View to display.
ConnectionStrings.config needs to exist on the server, since it is being referenced in web.config. It's an include file, so there doesn't necessarily have to be anything in it. But if it is being referenced, it needs to be included on the server, so just copy it there with your FTP program.