Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有谁知道为什么在运行 asp.net mvc 单元测试项目时无法获取虚拟路径?是因为它在 TestResults 文件夹下创建了一个 Temp 文件夹。??
如果没有运行 Web 服务器,它会从哪里来?
您必须在您的模拟 HttpContext 中模拟与路径相关的任何内容,例如:
request.Expect(req => req.AppRelativeCurrentExecutionFilePath).Returns("~/"); response.Expect(res => res.ApplyAppPathModifier(It.IsAny<string>())) .Returns((string virtualPath) => virtualPath);