无法下载包含&的文件名符号 [英] unable to download Filename containing & symbol

查看:299
本文介绍了无法下载包含&的文件名符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个MVC应用程序。我有一个Model对象,它在服务器上保存文件名和路径。



在一些for循环中(显示表中的文件)我是绑定锚(动态标记'')href属性



Hi
I have an MVC Application. I have a Model object which holds File Name and Path on the server.

In some for loop (to display files in table) i am binding anchor(
tag''s) href property dynamically as

<td>
   <a href = "@item.Path"> @item.Name </a>
</td>





这完美无缺,直到任何我的文件名包含例如''&''之类的符号。



之前我在传递包含''&''的文本时遇到同样的问题请求参数。我已经通过javascript中的encodeURIComponent修复了它。



但我无法对文件做同样的事情,请建议。



问候。

推荐答案

您需要正确呈现文件名,并且是各种字符编码的第一个字符。用&替换它(没有空格)。
You need to render the filename correctly, & is the first character of encoding for various chars. Replace it with & amp; ( without the space ).


实际,您可以在MVC中使用@ Html.Raw(item.Path)来使其无需编码即可呈现。
Actual, you can use @Html.Raw(item.Path) in MVC to get it to render without encoding.


这篇关于无法下载包含&amp;的文件名符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆