ASP.NET 4.0中Web应用程序项目的相对路径?
大家好,我有一个项目,我引用了我的图表的服务...并且我有硬编码的网址,例如 -
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果它们总是位于同一台计算机上,您可以考虑从 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.