【问题标题】:Null reference on MVC 2 ServerMVC 2 服务器上的空引用
【发布时间】:2011-04-23 08:28:44
【问题描述】:

我正在用 VS2010 编写一个 MVC 2.0 应用程序。在我的 Windows 7 Ultimate 64 位机器上,它运行良好。在我的笔记本电脑(Windows 7 Home Premium,32 位)上,当我调用 MapPath 时,服务器上的引用为空。

        public ActionResult Index()
    {
        ContentModel content = new ContentModel();
        content.Content = ContentInterface.GetHtmlContent(Server.MapPath("~"), "Home");
        content.Ads = ContentInterface.GetPartialAds(Server.MapPath("~"), AdCount);
        content.Testimonials = ContentInterface.GetTestimonials();

        return View(content);
    }

我已经通过 Webinstaller 安装了 MVC 2,我用 IIS 重新注册了 .Net 4。我已确认 IIS 6 WMI 兼容模式。

有什么想法吗?

【问题讨论】:

  • 你的问题看起来很简单,但这是一个令人困惑的问题。您是否有机会发布异常详细信息及其报告的来源,以防万一那里有启发性?
  • 这里是异常:System.NullReferenceException 未被用户代码处理 Message=Object reference not set to an object of an instance。 Source=WeldLink StackTrace: 在 WeldLink.Controllers.HomeController.Index() 中 C:\Users\steve\Documents\WeldLink\WeldLink\Controllers\HomeController.cs: 第 39 行在 WeldLink.Tests.Controllers.HomeControllerTest.Index() 中C:\Users\steve\Documents\WeldLink\WeldLink.Tests\Controllers\HomeControllerTest.cs:line 22 InnerException:
  • 我还要注意,我还有其他 MVC 2 应用程序可以在同一系统上开发和运行。
  • @Steve - 当您更新问题时,请编辑问题以添加附加信息,不要将其作为评论发布,因为它更难阅读。

标签: asp.net-mvc visual-studio-2010 asp.net-mvc-2


【解决方案1】:

想通了:权限。我授予 IUSR 完全控制权,它现在可以工作了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-02-23
    • 1970-01-01
    • 2011-02-15
    • 2014-05-22
    • 2011-02-15
    • 2021-01-29
    • 1970-01-01
    相关资源
    最近更新 更多