简体   繁体   中英

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 to 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM