剃刀视图在本地工作,但不在Azure网络应用程序
问题描述:
我有一个奇怪的问题。我有一个页面,其中包含以下URL:/ShowLead?leadid=3&customerid=9626
。当我进入本地本页面和我在Visual Studio 它的工作原理运行,但是当我在网上输入它,我得到以下错误:剃刀视图在本地工作,但不在Azure网络应用程序
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>
我屁股ume问题是Layout = null
,但我想要的是这个视图不使用主控,但是像这样的vanila页面起作用。
答
您确定此视图包含在您的项目中,因为它将在本地工作,但发布的文件夹不包含您的索引视图。
您确定此视图包含在您的项目中,因为它将在本地工作,但发布的文件夹不包含您的索引视图。 – DSR
您是否确认远程服务器中存在Showlead文件夹和Index.cshtml文件?当'Layout = null'不能找到视图时也不会出现问题。 –
你当然是对的。建立行动是错误的...留下一个答案,我会接受! –