Session lost when using hostname instead of IP address (IE)

梦想的初衷 提交于 2019-12-02 06:10:23

问题


I'm learning asp.net mvc 2, it's very excting with me.

I has built a small MVC2 application, it is working fine in built it ASP.net Development Server. However, there're something wrong when have it deployed in IIS 7.5, Window Server 2008 R2 Enterprise. Session is awlays null when I access the application by IE and use hostname to specify the url.

Using IE (IE 7 or IE8) to access my application with link http://localhost/ or ipaddress => every working fine

But when I use IE (IE 7 or IE8) to access my application with link http:/hostname/ => session always null

I'm supprised while FireFox working fine in all cases, both of built in ASP.net Development Server and IIS server, both cases hostname and ip and localhost.

I really appreciate your advise!

Thanks


回答1:


I figured out the problem, that caused by the web server host name which has an underscore. Thanks all.




回答2:


@khoailang

I had the same problem and figured out the issue with IE occurs when you use a machine name with underscore in its name.

eg. machine_01/app/Default.aspx => Session Lost!

while 10.100.0.1/app.Default.aspx works where 10.100.0.1 is the IP for machine_01.

Any idea why this happens?




回答3:


If you are using cookie based sessions it could be that you are not allowing cookies in IE.

I believe by default the session identity is stored in a cookie between requests to allow the application to reconnect to its session data.

You can use cookieless sessions which append the session identity to the url as a querystring, or at least in webforms - I'm not sure how this behaves in mvc.




回答4:


As per http://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names:

The Internet standards (Request for Comments) for protocols mandate that component hostname labels may contain only the ASCII letters 'a' through 'z' (in a case-insensitive manner), the digits '0' through '9', and the hyphen ('-'). No other symbols, punctuation characters, or white space are permitted.

Underscores in hostnames cause a number of strange, inconsistent problems, including problems sending mail, sql replication not working in unexpected ways, and most RDP connections failing.



来源:https://stackoverflow.com/questions/4303579/session-lost-when-using-hostname-instead-of-ip-address-ie

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!