【问题标题】:Routing error with IIS 7 versus IIS Express generating HTTP 404 errorsIIS 7 的路由错误与 IIS Express 生成 HTTP 404 错误
【发布时间】:2013-02-08 09:37:35
【问题描述】:

我将 MVC 3 与 Visual Studio 2010 和 C# 4.0 一起使用。我的应用程序在 Visual studion 的 IIS Express 下以及部署到远程生产 IIS 7.5 服务器时可以正常工作。

当我切换到在我的开发系统上使用完整的 IIS 7.5 服务器时,我的两个控制器中的操作突然开始出现 HTTP 404 错误。其他控制器正常工作。这可以从 Visual Studio 或直接从 IIS 运行应用程序。

我看不出配置差异。

表现出这种行为的控制器之一是:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Configuration;
using Mbrrace.ApplicationServices.Validation;

namespace Mbrrace.WebUI.Areas.Validation.Controllers
{
    public class ValidationController : Controller
    {
        //
        // GET: /Validation/Validation/

        [HttpGet]
        public JsonResult PostcodeCheck([Bind(Prefix = "perinatalView")]AddressViewModel model)
        {

            //  postcode has already been checked for correct format
            //  now look it up to see if it exists

            if (PostcodeChecks.CheckPostcodeExists(ConfigurationManager.ConnectionStrings["CommonCodeEntities"].ConnectionString, model.Postcode))
            {
                return Json(true, JsonRequestBehavior.AllowGet);
            }

            return Json("This postcode was not found in the database", JsonRequestBehavior.AllowGet);

        }

        [HttpPost]
        public JsonResult PostcodeExtendedCheck(String Postcode)
        {

            // check if it exists or of it's sector exists (all but last two characters

            string message = PostcodeChecks.PostcodeExtendedCheck(ConfigurationManager.ConnectionStrings["MbrraceCommonCodeEntities"].ConnectionString,
                Postcode, Postcode.Substring(0, Postcode.Length - 2));
            string success = (message.Length == 0) ? "OK" : "NO";
            var result = new { Success = success, Message = message };

            return Json(result, JsonRequestBehavior.AllowGet);
        }

        public class AddressViewModel
        {
            public string Postcode { get; set; }
        }

    }
}

这在 IIS Express 中的行为与预期相同,并已部署到 IIS。 IIS连接项目调试时会抛出404错误。

谁能解释为什么会产生 404 错误?

【问题讨论】:

  • 您是否将托管管道模式设置为集成到应用程序池中?
  • 谢谢,是的,我们这样做了,同时检查了“允许 32 位应用程序”
  • 你能显示那些控制器的路由吗?动作有什么属性吗?是否有任何自定义处理程序正在运行?
  • 你的服务器上是否安装了this update,但本地没有安装?
  • 在 Express 和“常规”Web 服务器中打开跟踪日志记录,以找出它在 Express 服务器上应该的位置,并匹配进程/路由在你的“常规”上。某些配置可能不同。非“快速”版本具有更多功能,这正在改变行为。

标签: asp.net-mvc http iis-7 asp.net-mvc-routing


【解决方案1】:

我首先想到的是IIS configuration。 在集成模式下配置的站点是否有 Application Pool?

您也可以尝试添加global.asax 和Application_OnError 并在那里签入server.GetLastError

另一个选项应该是使用 Glimpse 来查看您可能遇到的路由问题(如果是路由问题)

如果您没有发现问题,请在此之后发布更多有关 IIS 配置的详细信息

【讨论】:

    猜你喜欢
    • 2015-10-18
    • 2012-05-03
    • 1970-01-01
    • 2017-07-04
    • 1970-01-01
    • 1970-01-01
    • 2012-05-22
    • 2012-08-17
    • 2011-10-13
    相关资源
    最近更新 更多