請幫助我建立了我的網站[日文版]使用重寫模塊它工作得很好,並很好地重寫我的網址,但是當我插入日本數據時不重寫我的網址並得到[錯誤的請求錯誤]。日本字符與IIS7 URL重寫asp.net
備註如果網站數據是英文的,運行良好。
更新
這是我重寫的webconfig代碼樣本
<rewrite url="~/Seightseeing/(.+)/(.+).aspx" to="~/ExcursionsDetails.aspx?packageId=$1"/>
<rewrite url="~/LocalExperience/(.+)/(.+).aspx" to="~/ExcursionsDetails.aspx?packageId=$1"/>
<rewrite url="~/ShoreExcursions/(.+)/(.+).aspx" to="~/ExcursionsDetails.aspx?packageId=$1"/>
我認爲[錯誤的請求]的原因錯誤是URL也許有特殊字符雖然GenerateURL方法包含除了清除特殊字符 我發佈了下面的方法
public static string GenerateURL(object Title, object strId)
{
string strTitle = Title.ToString();
#region Generate SEO Friendly URL based on Title
//Trim Start and End Spaces.
strTitle = strTitle.Trim();
//Trim "-" Hyphen
strTitle = strTitle.Trim('-');
strTitle = strTitle.ToLower();
char[] chars = @"$%#@!*?;:~`+=()[]{}|\'<>,/^&"".".ToCharArray();
strTitle = strTitle.Replace("c#", "C-Sharp");
strTitle = strTitle.Replace("vb.net", "VB-Net");
strTitle = strTitle.Replace("asp.net", "Asp-Net");
//Replace . with - hyphen
strTitle = strTitle.Replace(".", "-");
//Replace Special-Characters
for (int i = 0; i < chars.Length; i++)
{
string strChar = chars.GetValue(i).ToString();
if (strTitle.Contains(strChar))
{
strTitle = strTitle.Replace(strChar, string.Empty);
}
}
//Replace all spaces with one "-" hyphen
strTitle = strTitle.Replace(" ", "-");
//Replace multiple "-" hyphen with single "-" hyphen.
strTitle = strTitle.Replace("--", "-");
strTitle = strTitle.Replace("---", "-");
strTitle = strTitle.Replace("----", "-");
strTitle = strTitle.Replace("-----", "-");
strTitle = strTitle.Replace("----", "-");
strTitle = strTitle.Replace("---", "-");
strTitle = strTitle.Replace("--", "-");
//Run the code again...
//Trim Start and End Spaces.
strTitle = strTitle.Trim();
//Trim "-" Hyphen
strTitle = strTitle.Trim('-');
#endregion
//Append ID at the end of SEO Friendly URL
strTitle = "~/Seightseeing/" + strId + "/" + strTitle + ".aspx";
return strTitle;
}
你可以顯示你的重寫規則和例子嗎? – matk 2011-06-14 07:57:10