Does PostedFile.FileName work differently in .Net 4.0?

a 夏天 提交于 2019-12-10 10:19:42

问题


I'm working on an ASP.Net site which allows users to link documents using a UNC path. This site is used by a customer of ours for internal processes, so all users on their domain should have access to the UNC path.

When a user wants to add a linked document, they select the file using a FileUpload control. Previously in .Net 2.0, the control's PostedFile.FileName property returned the filename and the full UNC path. Now we are using .Net 4.0 and it only returns the filename.

Here's my main question: Does PostedFile.FileName work differently in .Net 4.0 compared to 2.0?

If not, what else could cause this problem?


回答1:


I assume that it's not .NET but the internet explorer which growed up in security.

From here:

Additionally, the “Include local directory path when uploading files” URLAction has been set to "Disable" for the Internet Zone. This change prevents leakage of potentially sensitive local file-system information to the Internet. For instance, rather than submitting the full path C:\users\ericlaw\documents\secret\image.png, Internet Explorer 8 will now submit only the filename image.png.

So you could

  1. Change the logic in the server-side code - It should not be dependent on the client-side file path location and should simply use the FileName property of the FileUpload control.

  2. Enable the IE 8 / IE 9 option to include the local directory path for the Internet Zone on the client-side(annoy the user).



来源:https://stackoverflow.com/questions/11403593/does-postedfile-filename-work-differently-in-net-4-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!