2010-10-10 34 views
3

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

 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兼容模式。

任何想法?

+0

你的问题似乎很简单,但这是一个令人困惑的问题。你有没有机会发布异常详情以及它报告的来源,以防有什么启示? – 2010-10-10 02:00:46

+0

以下是异常:System.NullReferenceException未被用户代码处理 Message =未将对象引用设置为对象的实例。 Source = WeldLink StackDrace: at WeldLink.Controllers.HomeController.Index()in C:\ Users \ steve \ Documents \ WeldLink \ WeldLink \ Controllers \ HomeController.cs:line 39 at WeldLink.Tests.Controllers.HomeControllerTest。在C:\ Users \ steve \ Documents \ WeldLink \ WeldLink.Tests \ Controllers \ HomeControllerTest.cs中的索引():第22行 InnerException: – Steve 2010-10-10 02:23:58

+0

我还会注意到,我有其他MVC 2应用程序可以开发和运行相同的系统。 – Steve 2010-10-10 02:25:56

回答

0

想通了:权限。我将完全控制权授予IUSR,现在就可以使用。

相关问题