问题标签 [virtual-path]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
444 浏览

asp.net-mvc - How can I trick MVC into rendering links based on a different virtual path?

I'm running a bunch of apps on discountasp.net with the subdomain addon. Since with shared hosting I can't have multiple IIS sites, I've also written an HTTP module that allows sites in subfolders to operate as if they are running in the root directory. So for example, instead of hosting my blog at dandoes.net/blog, I can host it at blog.dandoes.net (which is really actually dandoes.net). This has been working famously until now, when I'm trying to use it along with MVC.

The HtmlHelper generates its urls based on the virtual path of the application rather than the path data in the URL. So, if I'm on blog.dandoes.net and I want to link to blog.dandoes.net/Samples, I might have this code:

In normal circumstances, this would generate the url blog.dandoes.net/Samples, but instead, it generates blog.dandoes.net/Blog/Samples because the virtual directory is /Blog.

I could probably take 5 minutes and write something really hacky to do what I want, but I think it would be really interesting if I could get the MVC framework to do what I want.

So, is there any way I could get it to render the correct urls?

0 投票
2 回答
10055 浏览

asp.net - 如何在没有手动字符串解析的情况下将 url 转换为 asp.net 中的虚拟路径?

我已经看到有关从虚拟到绝对和 url 的转换的类似问题和答案,但是如何在没有手动字符串解析的情况下将 url 转换为虚拟路径?

例子:

我想将“ http://myserver/home.aspx ”转换为:“~/home.aspx”

我意识到上面的示例将是一个简单的字符串解析例程,但我正在寻找一个合适的解决方案,它可以适应 url 格式的变化。

0 投票
6 回答
22768 浏览

asp-classic - 在 asp 经典中获取完整路径的虚拟路径

如何在 ASP 经典中获取完整路径的虚拟路径。请注意,完整路径可能位于虚拟目录下,因此过于简单

方法行不通。

编辑:为了澄清,下面是一个例子

  • 完整的 Windows 文件路径(已知): \\MyServer\MyShare\Web\Site\Logs\Test.txt
  • 我的网站有一个名为Logs的虚拟目录,它指向\\MyServer\MyShare\Web\Site\Logs\
  • 虚拟路径(未知):/ Logs/ Text.txt
  • http路径(未知,需要): http://Site/Logs/Test.txt
  • 该代码位于主应用程序的 asp 页面中,而不是任何虚拟目录下。它位于与相关文件不同的服务器上。
  • IIS 6.0

    如何从完整文件路径中找到虚拟路径?

0 投票
2 回答
513 浏览

asp.net - asp.net - 我的路径是虚拟的吗?

是否有用于检查路径“虚拟性”的内置 asp.net 方法?

到目前为止,我能够做到的唯一方法是使用以下 try 块:

0 投票
1 回答
869 浏览

asp.net-mvc - 运行 ASP.NET MVC 单元测试项目时出现“未知的虚拟路径”!

有谁知道为什么在运行 asp.net mvc 单元测试项目时无法获取虚拟路径?是因为它在 TestResults 文件夹下创建了一个 Temp 文件夹。??

0 投票
1 回答
664 浏览

asp.net - ASP.NET:IsVirtualPath?

是否有确定 URI 是否为有效虚拟路径的功能?我得到了一个字符串,当字符串不是有效的虚拟路径时,需要对其使用 Server.MapPath() 而不抛出异常。

投票结束我的问题。答案是@ asp.net - 我的路径是虚拟的吗?.

0 投票
5 回答
24789 浏览

c#-3.0 - 如何使用物理路径打开WebConfiguration?

我有一个在 IIS7 中创建站点的 win 表单。一项功能需要打开 web.config 文件并进行一些更新。(连接字符串、smtp、模拟)

但是我没有虚拟路径,只有物理路径。

有什么办法我仍然可以使用 WebConfigurationManager?

我需要使用它查找部分和读/写的能力。

0 投票
1 回答
1799 浏览

c# - ASP.NET MVC:不知道 VirtualPath 是什么?

我有一个显示图像列表的视图,我现在正试图让它将图像显示为缩略图。好吧,我很确定我使用自定义 ActionResult 中的 VirtualPath 得到了大部分内容,尽管我似乎无法弄清楚它在制作 VirtualPath url 是什么?顺便说一句,我使用 XML 来存储来自图像的数据而不是 SQL。这是我的代码:

我的自定义 ActionResult 中的代码:

我的控制器的代码:

我的观点的代码:

任何帮助将不胜感激!!让我知道您有任何问题。:) 谢谢!

0 投票
2 回答
6812 浏览

c# - 测试 HtmlHelper 时如何解决图像路径问题?

我在测试 HTML Helper 时遇到了一个问题。基本上,我正在创建一个包含大量行、列和不同类型数据的网格。在标题中还有一个图像来通知用户数据是按哪一列排序的。但是,当我现在编写测试时(为时已晚,但迟到总比没有好?!),我得到这个错误:

“应用程序相对虚拟路径 '~/Images/SortingArrowUp.png' 不能设为绝对路径,因为应用程序的路径未知。”

我该如何解决这个问题。我可以理解在测试期间这可能是一个问题,并且图像可能不可用等等,但是这样做的正确方法是什么?

0 投票
2 回答
1033 浏览

wcf - 在 IIS 中创建 VirtualPath 以在 SharePoint 中托管 Web 服务

我正在尝试在 SharePoint 2007 (WSS 3.0) 中托管自定义 Web 服务,到目前为止,我已按照此处的说明创建一个简单的“Hello World”Web 服务:创建 WSS Web 服务

但是,当我在第 4 步中到达虚拟路径位时,我很难在 Visual Studio 中查看我是如何创建它的,然后部署以创建虚拟路径以使我的 Web 服务可访问。

任何人都可以帮我解决为 WSS 创建虚拟路径的问题,或者将我指向另一个指南以在 SharePoint 中创建和托管 Web 服务吗?

提前致谢...