作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有什么方法可以在我的网站的 IIS 中使用应用程序名称获取主机地址?为了让我的问题更清楚,这里有几个我想要的例子:
http://example.com/constructionSite/myController/myAction?blah=blahh
http://example.com/tr.Implementation/myOtherController/myAction?blah=blahh
http://example.com/anotherApplication/myController/myAction?blah=blahh
http://example.com/myOtherOtherController/myAction?blah=blahh
在我的 IIS 中,我有像上面那些应用程序 constructionSite, tr.Implementation, anotherApplication, myController
。我需要在 IIS 上获取带有应用程序名称的 URL,换句话说,直到 myController/.....
。而且 myController
不会总是同一个 Controller ,所以我不能使用 .IndexOf()
方法。
我尝试使用 System.Web.HttpContext.Current.Request.Url.AbsoluteUri, System.Web.HttpContext.Current.Request.Url.AbsolutePath
这些路径,但它不满足我。
获取带有应用程序名称的 url 的适当方法应该是什么?
最佳答案
你可以尝试使用 Url.Content("~")
@string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Content("~"))
关于c# - 如何在 .net mvc 中获取带有应用程序名称的 url?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27101791/
我是一名优秀的程序员,十分优秀!