c# - Best approach to get current url from razor view with HTTPS -
i have razor view canonical meta tag current url parameter, url has https, i'm doing this:
string secureurl = string.isnullorwhitespace(httpcontext.current.request.url.absoluteuri) ? httpcontext.current.request.url.absoluteuri.replace("http://", "https://") : string.empty; <link rel="canonical" href="@secureurl" /> is best way https version of url?
you can use @url.action() method's fourth parameter change protocol , pass other parameters null current url https following.
@{ string secureurl = url.action(null, null, null, "https"); // current url https } <link rel="canonical" href="@secureurl" />
Comments
Post a Comment