Click here to Skip to main content
15,885,366 members
Articles / Web Development / ASP.NET

Switching Between HTTP and HTTPS Automatically

Rate me:
Please Sign up or sign in to vote.
4.91/5 (109 votes)
7 Jul 2005BSD10 min read 730.4K   8.4K   199  
An article on automatically switching between HTTP and HTTPS protocols without hard-coding absolute URLs.
<VisualStudioProject>
    <CSHARP
        ProjectType = "Web"
        ProductVersion = "7.10.3077"
        SchemaVersion = "2.0"
        ProjectGuid = "{B4341FEA-B179-4429-9114-E956C866DD11}"
    >
        <Build>
            <Settings
                ApplicationIcon = ""
                AssemblyKeyContainerName = ""
                AssemblyName = "SampleSecurity"
                AssemblyOriginatorKeyFile = ""
                DefaultClientScript = "JScript"
                DefaultHTMLPageLayout = "Flow"
                DefaultTargetSchema = "IE50"
                DelaySign = "false"
                OutputType = "Library"
                PreBuildEvent = ""
                PostBuildEvent = ""
                RootNamespace = "SampleSecurity"
                RunPostBuildEvent = "OnBuildSuccess"
                StartupObject = ""
            >
                <Config
                    Name = "Debug"
                    AllowUnsafeBlocks = "false"
                    BaseAddress = "285212672"
                    CheckForOverflowUnderflow = "false"
                    ConfigurationOverrideFile = ""
                    DefineConstants = "DEBUG;TRACE"
                    DocumentationFile = ""
                    DebugSymbols = "true"
                    FileAlignment = "4096"
                    IncrementalBuild = "false"
                    NoStdLib = "false"
                    NoWarn = ""
                    Optimize = "false"
                    OutputPath = "bin\"
                    RegisterForComInterop = "false"
                    RemoveIntegerChecks = "false"
                    TreatWarningsAsErrors = "false"
                    WarningLevel = "4"
                />
                <Config
                    Name = "Release"
                    AllowUnsafeBlocks = "false"
                    BaseAddress = "285212672"
                    CheckForOverflowUnderflow = "false"
                    ConfigurationOverrideFile = ""
                    DefineConstants = "TRACE"
                    DocumentationFile = ""
                    DebugSymbols = "false"
                    FileAlignment = "4096"
                    IncrementalBuild = "false"
                    NoStdLib = "false"
                    NoWarn = ""
                    Optimize = "true"
                    OutputPath = "bin\"
                    RegisterForComInterop = "false"
                    RemoveIntegerChecks = "false"
                    TreatWarningsAsErrors = "false"
                    WarningLevel = "4"
                />
            </Settings>
            <References>
                <Reference
                    Name = "System"
                    AssemblyName = "System"
                    HintPath = "..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"
                />
                <Reference
                    Name = "System.Drawing"
                    AssemblyName = "System.Drawing"
                    HintPath = "..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Drawing.dll"
                />
                <Reference
                    Name = "System.Data"
                    AssemblyName = "System.Data"
                    HintPath = "..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
                />
                <Reference
                    Name = "System.Web"
                    AssemblyName = "System.Web"
                    HintPath = "..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Web.dll"
                />
                <Reference
                    Name = "System.XML"
                    AssemblyName = "System.Xml"
                    HintPath = "..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
                />
            </References>
        </Build>
        <Files>
            <Include>
                <File
                    RelPath = "AssemblyInfo.cs"
                    SubType = "Code"
                    BuildAction = "Compile"
                />
                <File
                    RelPath = "Default.aspx"
                    SubType = "Form"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "Default.aspx.cs"
                    DependentUpon = "Default.aspx"
                    SubType = "ASPXCodeBehind"
                    BuildAction = "Compile"
                />
                <File
                    RelPath = "Default.aspx.resx"
                    DependentUpon = "Default.aspx.cs"
                    BuildAction = "EmbeddedResource"
                />
                <File
                    RelPath = "Global.asax"
                    SubType = "Component"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "Global.asax.cs"
                    DependentUpon = "Global.asax"
                    SubType = "Code"
                    BuildAction = "Compile"
                />
                <File
                    RelPath = "Global.asax.resx"
                    DependentUpon = "Global.asax.cs"
                    BuildAction = "EmbeddedResource"
                />
                <File
                    RelPath = "Login.aspx"
                    SubType = "Form"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "Login.aspx.cs"
                    DependentUpon = "Login.aspx"
                    SubType = "ASPXCodeBehind"
                    BuildAction = "Compile"
                />
                <File
                    RelPath = "Login.aspx.resx"
                    DependentUpon = "Login.aspx.cs"
                    BuildAction = "EmbeddedResource"
                />
                <File
                    RelPath = "SiteMap.ascx"
                    SubType = "UserControl"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "SiteMap.ascx.cs"
                    DependentUpon = "SiteMap.ascx"
                    SubType = "ASPXCodeBehind"
                    BuildAction = "Compile"
                />
                <File
                    RelPath = "SiteMap.ascx.resx"
                    DependentUpon = "SiteMap.ascx.cs"
                    BuildAction = "EmbeddedResource"
                />
                <File
                    RelPath = "Styles.css"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "Web.config"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "Admin\AdminStuff.aspx"
                    SubType = "Form"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "Admin\AdminStuff.aspx.cs"
                    DependentUpon = "AdminStuff.aspx"
                    SubType = "ASPXCodeBehind"
                    BuildAction = "Compile"
                />
                <File
                    RelPath = "Admin\AdminStuff.aspx.resx"
                    DependentUpon = "AdminStuff.aspx.cs"
                    BuildAction = "EmbeddedResource"
                />
                <File
                    RelPath = "Admin\LastOne.aspx"
                    SubType = "Form"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "Admin\LastOne.aspx.cs"
                    DependentUpon = "LastOne.aspx"
                    SubType = "ASPXCodeBehind"
                    BuildAction = "Compile"
                />
                <File
                    RelPath = "Admin\LastOne.aspx.resx"
                    DependentUpon = "LastOne.aspx.cs"
                    BuildAction = "EmbeddedResource"
                />
                <File
                    RelPath = "Admin\MoreAdminStuff.aspx"
                    SubType = "Form"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "Admin\MoreAdminStuff.aspx.cs"
                    DependentUpon = "MoreAdminStuff.aspx"
                    SubType = "ASPXCodeBehind"
                    BuildAction = "Compile"
                />
                <File
                    RelPath = "Admin\MoreAdminStuff.aspx.resx"
                    DependentUpon = "MoreAdminStuff.aspx.cs"
                    BuildAction = "EmbeddedResource"
                />
                <File
                    RelPath = "images\Secure.gif"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "images\Unsecure.gif"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "Lib\PopupCalendar.aspx"
                    SubType = "Form"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "Lib\PopupCalendar.aspx.cs"
                    DependentUpon = "PopupCalendar.aspx"
                    SubType = "ASPXCodeBehind"
                    BuildAction = "Compile"
                />
                <File
                    RelPath = "Lib\PopupCalendar.aspx.resx"
                    DependentUpon = "PopupCalendar.aspx.cs"
                    BuildAction = "EmbeddedResource"
                />
                <File
                    RelPath = "Members\FAQ.aspx"
                    SubType = "Form"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "Members\FAQ.aspx.cs"
                    DependentUpon = "FAQ.aspx"
                    SubType = "ASPXCodeBehind"
                    BuildAction = "Compile"
                />
                <File
                    RelPath = "Members\FAQ.aspx.resx"
                    DependentUpon = "FAQ.aspx.cs"
                    BuildAction = "EmbeddedResource"
                />
                <File
                    RelPath = "Members\FeatureTour.aspx"
                    SubType = "Form"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "Members\FeatureTour.aspx.cs"
                    DependentUpon = "FeatureTour.aspx"
                    SubType = "ASPXCodeBehind"
                    BuildAction = "Compile"
                />
                <File
                    RelPath = "Members\FeatureTour.aspx.resx"
                    DependentUpon = "FeatureTour.aspx.cs"
                    BuildAction = "EmbeddedResource"
                />
                <File
                    RelPath = "Members\ViewStatistics.aspx"
                    SubType = "Form"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "Members\ViewStatistics.aspx.cs"
                    DependentUpon = "ViewStatistics.aspx"
                    SubType = "ASPXCodeBehind"
                    BuildAction = "Compile"
                />
                <File
                    RelPath = "Members\ViewStatistics.aspx.resx"
                    DependentUpon = "ViewStatistics.aspx.cs"
                    BuildAction = "EmbeddedResource"
                />
                <File
                    RelPath = "Members\Welcome.aspx"
                    SubType = "Form"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "Members\Welcome.aspx.cs"
                    DependentUpon = "Welcome.aspx"
                    SubType = "ASPXCodeBehind"
                    BuildAction = "Compile"
                />
                <File
                    RelPath = "Members\Welcome.aspx.resx"
                    DependentUpon = "Welcome.aspx.cs"
                    BuildAction = "EmbeddedResource"
                />
                <File
                    RelPath = "Members\Secure\MemberInfo.aspx"
                    SubType = "Form"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "Members\Secure\MemberInfo.aspx.cs"
                    DependentUpon = "MemberInfo.aspx"
                    SubType = "ASPXCodeBehind"
                    BuildAction = "Compile"
                />
                <File
                    RelPath = "Members\Secure\MemberInfo.aspx.resx"
                    DependentUpon = "MemberInfo.aspx.cs"
                    BuildAction = "EmbeddedResource"
                />
                <File
                    RelPath = "Members\Secure\ViewOrderHistory.aspx"
                    SubType = "Form"
                    BuildAction = "Content"
                />
                <File
                    RelPath = "Members\Secure\ViewOrderHistory.aspx.cs"
                    DependentUpon = "ViewOrderHistory.aspx"
                    SubType = "ASPXCodeBehind"
                    BuildAction = "Compile"
                />
                <File
                    RelPath = "Members\Secure\ViewOrderHistory.aspx.resx"
                    DependentUpon = "ViewOrderHistory.aspx.cs"
                    BuildAction = "EmbeddedResource"
                />
            </Include>
        </Files>
    </CSHARP>
</VisualStudioProject>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The BSD License


Written By
Web Developer
United States United States
I began programming on my Commodore 64 at around the age of 12. After migrating to DOS and then Windows, I decided to take on the Web. Several languages and platforms later, I have settled in with .NET nicely. I am currently the owner of a software consulting company and lead application developer for a learning-based technology consultation company.

The love of a finished application is usually at war with the desire to improve it as soon as it's released (they're never really finished).

Comments and Discussions