How to Generate absolute urls with https in MVC3?

前端 未结 4 1762
天命终不由人
天命终不由人 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:26

    A solution that doesn't use extension methods or hardcode the protocol, as suggested by @BlackTigerX:

    Url.RouteUrl("Default", new { Action = "About" }, Request.Url.Scheme)
    

    as suggested in the following article: http://captaincodeman.com/2010/02/03/absolute-urls-using-mvc-without-extension-methods/

提交回复
热议问题