By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,683 Members | 1,597 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,683 IT Pros & Developers. It's quick & easy.

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

P: n/a

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.

Background:
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
event:

....
LoadConfig()

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

System.Web.HttpContext.Current.Response.Redirect(C Str(Session("URLRootSecure"))
+ "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
error:

'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
present.

- 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!

Martin

Nov 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.