如何在C#.NET Web应用程序中上传到服务器上的文件的URL?

发布于 2025-01-27 20:36:46 字数 240 浏览 1 评论 0 原文

我目前正在处理一个C#.NET Web应用程序,该应用程序支持用户上传文件上传的文件。我正在使用外部WhatsApp API,需要使用URL访问这些文件。因此,我想知道我应该将什么URL传递到API,以便它可以访问服务器上的文件。

URL会像:base_url/file_path/file_name一样?

另外,我必须在相同的路由配置文件中进行哪些更改(因为目前,默认URL模式是base_url/Controller/Action)

I am presently working on a C#.net Web Application which supports file uploads to the server by users. I am using an external WhatsApp API which needs to access these files using a URL. So, I am wondering as to what URL should I pass to the API so that it can access files on the server.

Will the URL be something like: base_url/file_path/file_name?

Also, what changes will I have to make in the route configuration file for the same (because, presently the default url pattern is base_url/controller/action)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你げ笑在眉眼 2025-02-03 20:36:46

基于上述讨论,我可以看到“ docundmessage”是其询问的模型。我有两种处理方法。您可以根据系统设计选择任何。

  1. 这是您的应用不需要任何云参与的方法。无论在IIS(前提)或任何云服务应用程序中托管不管,它都将起作用。但是只有要求是文件文件夹结构中需要文件。

解决方案: - 在根目录下创建虚拟路径。因此,您的API/网站将在某些域下托管( https://example.com )。因此,您的虚拟目录路径将像( https://example.com/filelelelocation )。因此,您的整个文件路径将在此链接下发布。因此,对于您的文件,路径将为 https://abc.or/filelelocation/file_data

注意: - 为您的安全目的禁用目录访问。没有失败的

参考: - IIS虚拟路径

  1. 如果可能的话,将文件放入一些云存储(例如BLOB存储容器)中&获取斑点URL。您需要将URL存储在数据库中(用于重复使用或存储它,而不是致电多个时间云以获取路径)。

Based on the above discussion, i can see 'DocumentMessage' is the model where its asking. I have 2 ways to handle. you can pick any based on your system design.

  1. This is the approach where your app don't need any Cloud involvement. Irrespective of Hosting in IIS(on premise) or any Any Cloud service app, it will work. But only requirement is File need to be there in the Project folder structure.

Solution:- Create a Virtual path under your root directory. So your api/ website will be hosted under some domain(https://example.com) . So your Virtual directory path will be something like (https://example.com/fileLocation). So your entire file path will be published under this link. so for your File the path will be https://abc.or/fileLocation/file_Data

Note:- Disable the Directory access for your security purpose. Without fail

Reference:- For IIS Virtual Path
For Azure App service

  1. If possible put your file in some Cloud storage(e.g. Blob storage container) & fetch the blob Url. you need to store the URL in the Database(for reusing it or storing instead of calling multiple time to Cloud to get the path).
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文