Today I have encountered a problem, I spent 3 hours and a half for figuring it out. I need to make the applicationcompatible with muiltiple domain urls.
I need to get the country information when parsing the two urls: cn.xx.xxx.xxxx.com and web-cn.xx.xxx.xxxx.com
Here is my code :
//Detect country by subdomain and get first culture in Front (ex : cn.xx.xxx.xxxx.com ) //Add possibility of detect the culture in Contrib Front ( ex : web-cn.xx.xxx.xxxx.com ) if (Request.Url.Host.IndexOf('.') == 2 || Request.Url.Host.IndexOf('.') == 6) { string s = Request.Url.Host.Split('.')[0]; //Log.Error("host first part : " + s + "\n"); string l = s.Substring(s.Length - 2); //Log.Error("host culture : " + l + "\n"); Culture cult = GetCulture(l).FirstOrDefault(); }
I have two test cases in my recette envrionment, on called Contrib, the other call Front. They hold the same codes and same configurations. But in fact it works in one case and not the other one.
With confusions and frastration during 3 hours, I've found that it's because there is a tiny difference between their configurations in IIS 6.
It's just the parameter "DefaultDoc". My application's default page is "Default.aspx". It won't work if i don't indicate it in my IIS configuration. The case not working doesn't have this parameter.
<IIsWebVirtualDir Location ="/LM/W3SVC/98004751/root" AccessFlags="AccessRead | AccessWrite | AccessScript" AppFriendlyName="AP Contrib" AppIsolated="2" AppPoolId="AP" AppRoot="/LM/W3SVC/98004751/Root" AuthFlags="AuthAnonymous | AuthNTLM" DefaultDoc="Default.aspx,Default.htm,Default.asp,index.htm" DirBrowseFlags="EnableDirBrowsing | DirBrowseShowDate | DirBrowseShowTime | DirBrowseShowSize | DirBrowseShowExtension | DirBrowseShowLongDate | EnableDefaultDoc" MimeMap=".woff,application/x-woff" Path="G:\CONTRIB" ScriptMaps=""> </IIsWebVirtualDir>
AT LAST, it work for me. Enjoy coding!!!
I need to get the country information when parsing the two urls: cn.xx.xxx.xxxx.com and web-cn.xx.xxx.xxxx.com
What i need is simply "cn".
Here is my code :
//Detect country by subdomain and get first culture in Front (ex : cn.xx.xxx.xxxx.com ) //Add possibility of detect the culture in Contrib Front ( ex : web-cn.xx.xxx.xxxx.com ) if (Request.Url.Host.IndexOf('.') == 2 || Request.Url.Host.IndexOf('.') == 6) { string s = Request.Url.Host.Split('.')[0]; //Log.Error("host first part : " + s + "\n"); string l = s.Substring(s.Length - 2); //Log.Error("host culture : " + l + "\n"); Culture cult = GetCulture(l).FirstOrDefault(); }
I have two test cases in my recette envrionment, on called Contrib, the other call Front. They hold the same codes and same configurations. But in fact it works in one case and not the other one.
With confusions and frastration during 3 hours, I've found that it's because there is a tiny difference between their configurations in IIS 6.
It's just the parameter "DefaultDoc". My application's default page is "Default.aspx". It won't work if i don't indicate it in my IIS configuration. The case not working doesn't have this parameter.
<IIsWebVirtualDir Location ="/LM/W3SVC/98004751/root" AccessFlags="AccessRead | AccessWrite | AccessScript" AppFriendlyName="AP Contrib" AppIsolated="2" AppPoolId="AP" AppRoot="/LM/W3SVC/98004751/Root" AuthFlags="AuthAnonymous | AuthNTLM" DefaultDoc="Default.aspx,Default.htm,Default.asp,index.htm" DirBrowseFlags="EnableDirBrowsing | DirBrowseShowDate | DirBrowseShowTime | DirBrowseShowSize | DirBrowseShowExtension | DirBrowseShowLongDate | EnableDefaultDoc" MimeMap=".woff,application/x-woff" Path="G:\CONTRIB" ScriptMaps=""> </IIsWebVirtualDir>
AT LAST, it work for me. Enjoy coding!!!
本文详细阐述了如何通过调整IIS配置中的DefaultDoc参数,解决应用在不同环境下解析多域名URL时获取国家信息的问题。通过对比测试环境中的配置差异,最终定位并解决了应用在特定环境下的兼容性问题。
33

被折叠的 条评论
为什么被折叠?



