Monday, July 14, 2008

Solution to "An error occurred in the secure channel support" - VS 2003 & https redirection



A.) (Blow away/move) the application’s dll (i.e. [bin]\[foo.dll]). Note – if you just do a rename you will get and assembly binding error.

---------

Case (global.asax):

protected void Application_BeginRequest(Object sender, EventArgs e)
{
if(!(Request.Url.ToString().ToLower().StartsWith("https://")))
Response.Redirect(Request.Url.ToString().Replace("http://", "https://"));
}

On a dev box that does not support ssl (& if you are using ports that is another issue).

Compiles fine.

Close & reopen devenv & project …

Upon load, the devenv parses the ap_load dll to contact the web server (2003 uses IIS, 2005 uses Casini and may not demonstrate the same issues) however now the ap_load is redirecting the URI (protocol) the ap uses to go the web server, cannot find the site and barfs.

You are now left with a “You can’t get there from here” (http://www.mathacademy.com/pr/minitext/infinity/index.asp) situation.

By removing the compiled version of the project, the site (existence) is not validated at dev time but rather run time (which then at least allows you to still modify the code, say do a conditional redirection based on environment).



No comments: