FYI: Strange VS Behaviour with SSL Solution - But Why?

Discussion in 'ASP .Net' started by, Mar 6, 2005.

  1. Guest

    Dear Group

    I came accross a very annoying behaviour of Visual Studio, giving me
    six hours of headache till I found the solution.

    This post is mainly for fellow developers for reference as it took me
    ages reading through tons of posts till I found an answer. However, I'm
    also interested why Visual Studio behaves that way. If anyone has a
    theorie on it please let me know.

    I want to run a web application over SSL and installed a thwarte trial
    certificate on my local development machine in IIS 5. It all worked
    fine until I introduced the following code in my login page's page_load


    'Determine Connection Type
    If System.Web.HttpContext.Current.Request.IsSecureConnection = False
    'Redirect To Use SSL

    + "login.aspx")
    End If


    The session variable URLRootSecure is simply a value from an outside
    configuration text file which is loaded with a bunch of other
    configuration vales into session variables in the LoadConfig() routine.
    It reads: "https://localhost/myapp/"

    When debugging the application in Visual Studio all worked fine. It
    recognised a standard connection and redirected to a secure connection.
    However, the nightmare started to unfold once I had closed the project.
    When I wanted to open it again in Visual Studio I got the following

    'The web server reported the following error when attempting to create
    or openthe Web project located at the following URL:' ...
    'The host name in the certificate is invalid or does not match'.

    That seemed strange as the application worked still fine when accessing
    it in my browser with https:/localhost/myapp/login.aspx and I knew that
    it wasn't a fault with the certificate. Anyways, I went ahead and
    removed the certificate. Just to receive the following error when
    trying to open the project in Visual Studio again:

    'The web server reported the following error when attempting to create
    or openthe Web project located at the following URL:' ...
    'A connection with the server could not be established'.

    Again, that seemed weird as I had no problem opening other projects or
    to create a new web project and IIS was running. Several desperate
    attempts followed to get my project to open again, just naming a few:
    Ran aspnet_regiis.exe just in case, created and installed a new
    VeriSign trial certificate both without luck. Then I created a new web
    application and imported all forms and code into it. That seemed to be
    fine UNTIL I again closed Visual Studio. The same error occured when
    opening the project!

    After much frustration I found a post suggesting to delete my project
    DLL in the build folder. Once deleted, voila, I could open the project
    without any error! Once recompiled and closed, it all started again.

    So I went ahead, repeated the process, commented the line in my
    page_load where it redirects to https:, built the solution, closed and
    were able to open it without complaints! So now I know to uncomment
    that line in the production environment but not to touch it in
    development. Just as a side note, changing the URLRootSecure value in
    my text file to http:// etc throw the error:

    'The web server reported the following error when attempting to create
    or openthe Web project located at the following URL:' ...
    'The HTTP redirect request failed.'

    This raises several questions:

    - Why on earth does Visual Studio .NET 2003 do such a thing? It's weird
    that it not only seems to validate code but go so far to loading values
    from a text file into session variables and then to run a line of code
    just when I want to OPEN a web project! I thought that's a runtime
    thing when I actually debug the application.
    I mean it let's me save syntax errors and doesn't care about them when
    opening a project!

    - Why does it validate at all as it doesn't seem to care in case the
    project DLL is missing. Very contradictive. It should throw an error in
    this case too. But of course not, as a project DLL isn't always

    - And why does it let me debug the application and doesn't complain
    there and then, but throws cryptic errors when I want to open the
    project again?

    - Why do I get 'The HTTP redirect request failed.' for this line of
    code but not for any other response. redirect's I have in my code?

    At the moment all I can think of that this is total irrational
    behaviour and bs. If you have another view, please let me know.

    Thanks for your time and efforts!

    , Mar 6, 2005
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. 620
    Murat Tunaboylu
    Jan 6, 2004
  2. CW
  3. GreggTB
    May 24, 2005
  4. Replies:
  5. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Mark Rae
    Dec 21, 2006
  6. Mr. SweatyFinger
    Smokey Grindel
    Dec 2, 2006
  7. DeltaOne
    May 20, 2005
  8. ft310
    Jun 5, 2007