MVC应用程序中查询字符串的加密 [英] Encryption of query strings in MVC application

查看:131
本文介绍了MVC应用程序中查询字符串的加密的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在MVC应用程序上工作,我需要在其中发送一些值作为查询字符串.

我使用Base 64加密对查询字符串进行加密,还使用html编码技术对查询字符串进行编码和解码.

对于某些变量,它可以正常工作,但是当它在查询字符串中获得值"/"或"+"时,mvc会直截了当,提示未找到资源".

如何限制Base64仅生成不包含特殊字符的文本.

还是我可以使用其他任何加密方式.

请帮助我,这会浪费我的时间...

谢谢您

Hi Guys,

I am working on a mvc application , where i need to sent some values as querystrings.

I used Base 64 encryption to encrypt the querystrings and also used html encoding techniques to encode and decode the querystrings.

It''s working fine for some variables but when it gets a value "/" or "+" in the query string , mvc straight forward throughs an error saying "resource not found".

How can i restrict the Base64 to only generate text without the special characters.

Or is there any other ways of encryption which i can use.

Please help me guys, its killing my time...

thank you

推荐答案

您必须使用base64url这样的编码变体: http://fr.wikipedia.org/wiki/Base64 [ ^ ]

我不认为ASP.NET直接支持该编码.您可以编写自己的函数或进行编码,然后对URL进行编码.

无论如何在MVC中干净利落地进行操作,您可能都必须重写一堆东西.

您是手动进行所有编码还是扩展了MVC以支持该编码?
You have to use a variation of that encoding like base64url: http://fr.wikipedia.org/wiki/Base64[^]

I don''t think ASP.NET directly support that encoding. You can write your own functions or for do that encoding and then encode for URL.

Anyway to do it cleanly in MVC, you will probably have to override a bunch of stuff.

Are you doing all the encoding by hand or have you expanded MVC to support that?


Base64 是字符串 Encoding 方案,而不是加密技术.

不仅在 Asp.Net-MVC 中,而且在任何Web开发技术中,诸如QueryString中的"/"字符都对现有Url赋予了完全不同的含义.

看看下面的ASP.NET中查询字符串加密的链接.

ASP.NET的查询字符串加密

http://www.dotnetfunda.com/articles/article748-url-encryption-in -aspnet-.aspx

也请查看下面的" Asp.Net会话"链接.

http://msdn.microsoft.com/en-us/library/ms178581.aspx
Base64 is a string Encoding scheme and not an Encryption technique.

Not only in Asp.Net-MVC but in any Web-Development Technology character like "/"(in QueryString) gives altogether different meaning to the existing Url.

Have a look at below links for Query string encryption in ASP.NET.

Query string encryption for ASP.NET

http://www.dotnetfunda.com/articles/article748-url-encryption-in-aspnet-.aspx

Also have a look at below link for "Asp.Net Sessions".

http://msdn.microsoft.com/en-us/library/ms178581.aspx


这篇关于MVC应用程序中查询字符串的加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆