asp.netはどのようにURLの中で中国語、スペース、特殊な文字を使いますか?
cshtmlまたはaspx/ascxでリンクを作成する場合、パラメータが中国語の可能性があるなら、HttpUtility.UrlEnccode():
でも、このように書いても長すぎて面倒くさいです。だから、いつも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上のすべての類似の問題)
-
- [html] view plaincopy
- [email protected](" ", "/SFC/Users/Users2Roles?user=" + HttpUtility.UrlEncode(User.Identity.Name))
対応するアクションにおいては、通常通り「Decode」は必要ありません。
-
- html] view plaincopy
- 01.public ActionResult Users2Roles(string user)
- 02.{
- 03. ViewBag.User = user;
- 04. return View(SFCRoles.GetAllRoles());
- 05.}
- 06.[HttpPost]
- 07.public ActionResult Users2Roles(string user, FormCollection collection)
- 08.{
- 09. ViewBag.User = user;
- 10.
- 11. try
- 12. {
- 13. }
- 14.}
, , , “&”, : :
-
- [html] view plaincopy
- [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上のすべての類似の問題)