c# - ASP.NET HTTP to HTTPS redirect with www prefix -


i using simple code redirect http https on billing landing page:

if (!request.issecureconnection) {     // send user ssl      string servername =httputility.urlencode(request.servervariables["server_name"]);             string filepath = request.filepath;     response.redirect("https://" + servername + filepath); } 

i need check , add www url if not in url. need add code accomplish this?

like this:

if (!servername.startswith("www."))     servername = "www." + servername; 

Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -