如何编码url ASP.NET [英] How to encode url ASP.NET
本文介绍了如何编码url ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在浏览器中编码我的网址。
如果我有www.localhost:56789 / result / value / page?= 2 / ...
我想将其更改为www.localhost:56789 /结果/值/或www.localhost:56789 / result / value / 12psdkiu83c4uixjo1p329ur8yfh
我使用asp.net mvc C#来构建wesbite
我尝试过的事情:
我什么都没做。仍在搜索如何操作
I want to encode my url in browser.
If i have www.localhost:56789/result/value/page?=2/...
I want to change it to be www.localhost:56789/result/value/ or www.localhost:56789/result/value/12psdkiu83c4uixjo1p329ur8yfh
I use asp.net mvc C# to build by wesbite
What I have tried:
I haven't do anything. Still search how to do it
推荐答案
对于URL编码,您可以使用URLEncode()
参考: HttpServerUtility.UrlEncode方法(字符串)(System.Web) [ ^ ]
但是由于您的要求是只编码一段纯文本,更好的选项看起来是加密而不是编码,因为这会导致大文本,可以被别人解码。加密是一个更安全的选择。
检查以下文章的详细实施方法 -
使用C#和VB在ASP.Net中加密和解密QueryString参数值。净 [ ^ ]
希望,它有帮助:)
For URL Encode you can useURLEncode()
Reference: HttpServerUtility.UrlEncode Method (String) (System.Web)[^]
But as your requirement is to encode just a piece of plain text, the better option looks to encrypt rather than encoding as that can result in a large text and can be decoded by someone else. Encryption is a more secure option to this.
Check following article for detailed implementation approach-
Encrypt and Decrypt QueryString Parameter Values in ASP.Net using C# and VB.Net[^]
Hope, it helps :)
这篇关于如何编码url ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文