ASP.NET - Check for development machine or server
I have a https site which i am working on. The development machine would not support https and thus give me error. Is there any way to recognize that https will work for the current environment or not. My application sends out a email in which it replaces http with https. I want 开发者_如何学Goto place a check on that.
if(Request.IsLocal)
this returns Gets a value indicating whether the request is from the local computer.
and
if(Request.IsSecureConnection)
this returns Gets a value indicating whether the HTTP connection uses secure socckets (this is, HTTPS).
You could infact install a self-signed certificate on your development machine. The browser will throw a wobbly until you accept it as an exception, but it does allow you to test your site/application in both HTTP and HTTPS scenarios.
Use a configuration setting in your web.config file.
Use web.config transforms to set the value to use https when you deploy it to your production environment.
Alternatively if the issue is that your using the integrated cassini visual studio webserver for development on your local machine, you could try using IIS Express instead.
精彩评论