How to Generate absolute urls with https in MVC3?

前端 未结 4 1761
天命终不由人
天命终不由人 2020-12-16 12:40

I am using MVC3 and am trying to serve content from https, the problem is that when I call Url.Content the files are still served from http using a relative url. I thought t

4条回答
  •  爱一瞬间的悲伤
    2020-12-16 13:23

    If you don't want to "build" the url and just want the full path of the current page, this will do the trick

    Context.Server.UrlEncode(Context.Request.Url.AbsoluteUri)

    I know it's not as elegant as an Extension Method but thought of sharing it for educational purposes

提交回复
热议问题