ASP.NET 在 IIS 上返回 Class 名称而不是数据,但在生产环境中不返回
ASP.NET returning Class name instead of data on IIS, but not on production environment
我正在使用 RazorPDF 将 return PDF 作为视图。
问题是,当我 运行 在我的机器上时,代码工作正常,return 按我的意愿编辑 PDF,但是当我将代码上传到 Windows Server 2008 中的 IIS 时,代码returns "RazorPDF.PdfResult" 即 class 作为字符串的名称。
应用程序的其余部分在两种环境下都可以正常工作。
这是正确的 return 结果,在本地机器上:
right_return
这是在 windows 服务器上 运行ning 时的结果:wrong_return
代码:
public ActionResult OrcamentosResultado(LogisticaModel model, string pdf)
{
//Some code
if (pdf == "pdf")
{
PdfResult retorno = new PdfResult(model, "ComprasPDF");
return retorno;
}
//Some more code
}
我正在使用 ASP.NET 4.0 和 System.Web.MVC 3.0
我发现了问题,它与我在上面评论中提到的问题有点相同 Error converting MVC4 view to PDF with Rotativa or RazorPDF
问题是服务器中的 System.web.mvc dll 版本 2.0.0.0(位于 C:/Windows/assembly)与我的 bin 文件夹中的同一个 dll 版本 3.0 之间存在冲突。 0.1
正如@SqlSurfer 指出的那样,2.0.0.0 mvc dll 具有一些 ToString 行为。
为了修复它,我只是更改了 Web.config 以查找 bin 文件夹中的 dll,而不是服务器
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.1" />
</dependentAssembly>
</assemblyBinding>
我的本地计算机没有发生错误,因为我的计算机在 windows/assembly 文件夹中没有 System.web.mvc dll。
感谢大家
我正在使用 RazorPDF 将 return PDF 作为视图。 问题是,当我 运行 在我的机器上时,代码工作正常,return 按我的意愿编辑 PDF,但是当我将代码上传到 Windows Server 2008 中的 IIS 时,代码returns "RazorPDF.PdfResult" 即 class 作为字符串的名称。 应用程序的其余部分在两种环境下都可以正常工作。
这是正确的 return 结果,在本地机器上: right_return
这是在 windows 服务器上 运行ning 时的结果:wrong_return
代码:
public ActionResult OrcamentosResultado(LogisticaModel model, string pdf)
{
//Some code
if (pdf == "pdf")
{
PdfResult retorno = new PdfResult(model, "ComprasPDF");
return retorno;
}
//Some more code
}
我正在使用 ASP.NET 4.0 和 System.Web.MVC 3.0
我发现了问题,它与我在上面评论中提到的问题有点相同 Error converting MVC4 view to PDF with Rotativa or RazorPDF
问题是服务器中的 System.web.mvc dll 版本 2.0.0.0(位于 C:/Windows/assembly)与我的 bin 文件夹中的同一个 dll 版本 3.0 之间存在冲突。 0.1
正如@SqlSurfer 指出的那样,2.0.0.0 mvc dll 具有一些 ToString 行为。
为了修复它,我只是更改了 Web.config 以查找 bin 文件夹中的 dll,而不是服务器
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.1" />
</dependentAssembly>
</assemblyBinding>
我的本地计算机没有发生错误,因为我的计算机在 windows/assembly 文件夹中没有 System.web.mvc dll。
感谢大家