简体   繁体   中英

ASP.NET HTTPS and RelativeUrls

I have a site with an SSL cert for www.foo.com. What is the cleanest way redirect requests to the https:// prefix? Do I have to build links server side instead of relying on resolving urls with relative paths, ~/?

Also, say I redirect to an https:// page, the links on the page are all created in a master page and are resolved with relative paths. If the user clicks on any of the navigation elements they are essentially stuck on the https:// path, what is the best way to clean that up?

The paths all need to work in the dev (localhost), staging, and production environments.

No you dont need to do anything,

Unless you issue a fully qualified url, your every relative url redirects and paths are always considered along with https:// for example,

Your url of page is https://mysite/folder1/page.aspx and if you issue Response.Redirect("/folder2/page2.aspx") then web server only issues relative url "/folder2/page2.aspx" but the client (IE/FF2/Safari) they append " https://mysite " before the url.

So as long as you use relative urls in your project, you are safe.

您可以在html中设置<base>标记,这意味着所有内容都将相对于该基本url。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM