2009-07-28 55 views
0

我觉得我失去了一些东西在HTTPS ...我应该在web.config中声明https吗?

目前我使用此为所需的页面从HTTP重定向到HTTPS

If Not Request.IsSecureConnection Then 
    Dim serverName As String = HttpUtility.UrlEncode(Request.ServerVariables("SERVER_NAME")) 
    Dim filePath As String = Request.FilePath 
    Response.Redirect(("https://" & serverName) + filePath) 
    End If 

我应该申报的地方在web.config中的绝对链接为https?

p.s.我的链接是相对的

回答

0

如果你想使用一个静态的URL,那么你可以在你的web配置补充一点:

<appSettings> 
    <add key="url" value="http://www.yoursite.com" /> 
</appSettings> 

之后,你可以得到任何你想要这样的地方该值:

string strHost = ConfigurationManager.AppSettings.Get("url").ToString(); 

希望这会解决你的问题。

相关问题