Request.ApplicationPath 返回/或者iis下目录。如果个人网站是在iis网站下面新建的目录aaa,返回如:/aaa
Request.Url.Authority 返回域名和端口或ip 如:localhost:1897
var applicationPath =Request.ApplicationPath.Length>1 ? Request.ApplicationPath :"";//防止多一个斜线。当是网站时候,返回/aaa 。当是网站下的目录,返回空字符
var path ="http://"+Request.Url.Authority+applicationPath +"/upload/文件.txt"; //最终:http://localhost:1897/upload/文件.txt 或http://localhost:1897/aaa/upload/文件.txt
时间: 2024-11-10 16:51:30