【发布时间】:2011-01-11 05:48:05
【问题描述】:
我正在visual web developer 2010 express上开发我的MVC3应用程序, 通过在 MVC2 上迁移我的 MVC3 (cshtml) 文件。
它在使用模拟器的本地系统上运行良好,但是一旦我在 azure 上部署应用程序,它就会出现运行时错误。
例子:
The layout page "~/Views/Shared/test_page.cshtml" could not be found at the following path: "~/Views/Shared/test_page.cshtml".
Source Error:
Line 8: //Layout = "~/Views/Shared/upload.cshtml";
Line 9: //Layout = "~/Views/Shared/_Layout2.cshtml";
Line 10: Layout = "~/Views/Shared/test_page.cshtml";
Line 11: }
Line 12: else
代码如下:
_ViewStart.cshtml file
@{
string AccId = Request.QueryString["AccId"].ToString();
if (AccId=="0")
{
//Layout = "~/Views/Shared/upload.cshtml";
//Layout = "~/Views/Shared/_Layout2.cshtml";
Layout = "~/Views/Shared/test_page.cshtml";
}
else
{
string LayOutPagePath = MVCTest.Models.ComponentClass.GetLayOutPagePath(AccId);
Layout = LayOutPagePath;
}
}
…………
但是该页面存在,并且在 azure 模拟器上运行良好,但在 azure cloud 中却不行。
test_page.cshtml 代码
@{
var result = "1234567890";
var temp_xml = MVCTest.Models.ComponentClass.GetTemplateAndTheme("1");//returning xml
string LayOutPagePath = MVCTest.Models.ComponentClass.GetLayOutPagePath("1");//returning string
}
@RenderBody()
<h1>test_page</h1>
<h4>@temp_xml</h4>
<h4>@result</h4>
<h4>@LayOutPagePath</h4>
【问题讨论】: