【问题标题】:Azure application working on emulator but not on azure cloudAzure 应用程序在模拟器上运行,但在 azure 云上不运行
【发布时间】: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>

【问题讨论】:

    标签: azure emulation


    【解决方案1】:

    我在这里找到了我的解决方案.. 当我在 MVC2 上创建 cshtml 文件时,我手动将扩展名从 aspx 更改为 cshtml。 其余的您将通过下面的链接了解。

    http://blog.andreloker.de/post/2010/07/02/Visual-Studio-default-build-action-for-non-default-file-types.aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-08
      • 2016-09-02
      相关资源
      最近更新 更多