【发布时间】:2016-08-20 23:53:04
【问题描述】:
我刚刚发布了一个在开发中运行良好的应用程序,但是当我将它上传到服务器时,当我尝试预渲染特定视图时它失败了。
返回视图的简单 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 助手乐于在本地而不是在服务器上做呢?
【问题讨论】:
标签: c# asp.net-mvc reactjs