How do I encrypt URLs in ASP.NET MVC?

前端 未结 4 1260
执笔经年
执笔经年 2021-01-03 03:51

I need to Encrypt the URLs in my ASP.NET MVC application.

Do I need to write the code in Global page in Route Collection to Encrypt all the URLs?

4条回答
  •  孤城傲影
    2021-01-03 04:06

    Encrypting an entire url, I agree, very bad idea. Encrypting url parameters? Not so much and is actually a valid and widely used technique.

    If you really want to encrypt/decrypt url parameters (which isn't a bad idea at all), then check out Mads Kristensen's article "HttpModule for query string encryption".

    You will need to modify context_BeginRequest in order to get it to work for MVC. Just remove the first part of the if statement that checks if the original url contains "aspx".

    With that said, I have used this module in a couple of projects (have a converted VB version if needed) and for the most part, it works like a charm.

    BUT, there are some instances where I have experienced some issues with jQuery/Ajax calls not working correctly. I am sure the module could be modified in order to compensate for those scenarios.

提交回复
热议问题