我刚刚发布了一个在开发中运行良好的应用程序,但是当我将它上传到服务器时,当我尝试预渲染特定视图时它失败了。
返回视图的简单 mvc 函数:
public ActionResult StandaloneReport(ReportPageData pageData)
{
return View(pageData);
}
简单的服务器端渲染:
@Html.React("Components.ReportDisplayContainer", new {.pageData = Model})
@Html.ReactInitJavaScript()
React.net 设置为使用预先打包的 js 包:
ReactSiteConfiguration.Configuration.SetLoadBabel(false)
.AddScriptWithoutTransform("~/Scripts/webpack/build/server.bundle.js");
ReactSiteConfiguration.Configuration.SetReuseJavaScriptEngines(false);
这在开发中一切正常,我在发布之前重新发布并删除了服务器上的所有文件,所以我不明白为什么它不能在服务器上工作..
我得到的错误是:
将“Components.ReportDisplayContainer”渲染为“react_phCzHNkR5Uq7r5UEzzqYrQ”时出错:脚本抛出异常:对象不支持属性或方法“来自”行:0 列:0
Line 61: @Html.React("Components.ReportDisplayContainer", New With {.pageData = Model})
我只能看到与 webpack 生成的这行代码有关:
return Array.from(arr);
那么为什么 react 助手乐于在本地而不是在服务器上执行此操作呢?

