ASP.NET 4.0中Web应用程序项目的相对路径?

发布于 2024-09-09 16:57:40 字数 244 浏览 1 评论 0原文

大家好,我有一个项目,我引用了我的图表的服务...并且我有硬编码的网址,例如 -

ViewData["weeklyGraphURL"] = "\"http://localhost:9713/MyProject/MyAction"+Id + "\"";

所以这个网址基本上是另一个项目控制器操作...并且我在一个解决方案中拥有这两个项目...是当我将其部署到网络服务器上时,有一种方法可以设置该项目的相对路径

Hi all I have a project that i reference the services for my graphs...and i have hardcoded urls something like -

ViewData["weeklyGraphURL"] = "\"http://localhost:9713/MyProject/MyAction"+Id + "\"";

So this url is basically another projects controller action...and i have both these projects in one solution...is there a way i could set a relative path to this project when I deploy it on the web server

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

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

发布评论

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

评论(1

梨涡 2024-09-16 16:57:40

如果它们总是位于同一台计算机上,您可以考虑从 Request.ServerVariables.Get("SERVER_NAME") 中读取服务器名称并用它替换 localhost 。

If they are always going to live on the same machine you could look at reading the server name out of Request.ServerVariables.Get("SERVER_NAME") and replacing localhost with that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文