asp.netはどのようにURLの中で中国語、スペース、特殊な文字を使いますか?


cshtmlまたはaspx/ascxでリンクを作成する場合、パラメータが中国語の可能性があるなら、HttpUtility.UrlEnccode():
   
   
   
   
  1.  
  2. [html] view plaincopy  
  3. [email protected](" ", "/SFC/Users/Users2Roles?user=" + HttpUtility.UrlEncode(User.Identity.Name))    
対応するアクションにおいては、通常通り「Decode」は必要ありません。
   
   
   
   
  1.  
  2. html] view plaincopy  
  3. 01.public ActionResult Users2Roles(string user)    
  4. 02.{    
  5. 03.    ViewBag.User = user;    
  6. 04.    return View(SFCRoles.GetAllRoles());    
  7. 05.}    
  8. 06.[HttpPost]    
  9. 07.public ActionResult Users2Roles(string user, FormCollection collection)    
  10. 08.{    
  11. 09.    ViewBag.User = user;    
  12. 10.    
  13. 11.    try    
  14. 12.    {    
  15. 13.    }    
  16. 14.}    
, , , “&”, : :
 
   
   
   
   
  1.  
  2. [html] view plaincopy  
  3. [email protected]("x", "/SFC/Categories/Delete?rootID=" + root.ID + "&id=" + Model.ID, showInNewWindow:false, returnUrl: HttpUtility.UrlEncode(Request.Url.ToString()))    
このHtml.Linkは私が自分で編集したHelperです。直接aを使ってもいいです。
でも、このように書いても長すぎて面倒くさいです。だから、いつもreturnUrlを使うなら、他のスレを参考してください。http://cheny.blog.51cto.com/3988930/1100102 最後の何行に2011-08-18の補足があります。二つの問題が重なってしまいました。 
参考できる:
http://stackoverflow.com/questions/3101823/extract-chinese-text-from-query-string
http://stackoverflow.com/questions/1380617/request-url-parameter
http://stackoverflow.com/search?q=Chinese+Parameeter+URL+asp.net(StockOverflow上のすべての類似の問題)