Razor 视图在本地有效,但在 Azure Web 应用中无效

Razor view works locally but not in Azure web app

我有一个奇怪的问题。我有一个包含以下内容的页面 URL: /ShowLead?leadid=3&customerid=9626 。当我在本地输入此页面并在 Visual Studio 中 运行 它有效 ,但是当我在线输入它时,我得到以下 错误 :

The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/ShowLead/Index.aspx
~/Views/ShowLead/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/ShowLead/Index.cshtml
~/Views/ShowLead/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml

Description: An unhandled exception occurred during the execution of the current web req

它作为完全标准的 Azure Web 应用程序托管。

这对我来说很奇怪,因为如果我们查看我的文件夹结构,我确实在 ~/Views/ShowLead/Index.cshtml:

处有一个 Razor 视图

我的控制器看起来像这样:

public class ShowLeadController : Controller
{

    // GET: ShowLead
    public ActionResult Index(int leadid, int customerid)
    {
        // some amazing code that creates my viewmodel

        return View(vm);
    }   
 }

视图本身是:

@model Asano.Websites.LeadSender.Models.ViewModels.ShowLeadViewModel

@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

</head>
<body style="padding-top: 20px; font-family: Helvetica">
    <div style="margin:25px;">
      // some of the best HTML the world has ever seen with inline styles
    </div>

</body>
</html>

我认为问题出在 Layout = null,但我想要的是这个视图不使用母版,而是像这样作为普通页面工作。

您确定此视图包含在您的项目中吗,因为它可以在本地工作但发布的文件夹不包含您的索引视图。