5

我将 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 错误吗?

4

1 回答 1

0

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

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

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

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

于 2013-06-05T17:23:44.187 回答