简体   繁体   English

隐藏来自URL asp.net C#的查询字符串

[英]Hide query string from URL asp.net c#

I have this following url: 我有以下网址:

http://www.example.com?user=Ana and I want to get http://www.example.com?Ana http://www.example.com?user=Ana ,我想获取http://www.example.com?Ana

How can I get it? 我怎么才能得到它?

You can route example.com/Ana to Home/Index with parameter (you can change controller and action to what is needed). 您可以使用参数将example.com/Ana路由到Home / Index(可以将控制器和操作更改为所需的内容)。 Just add new route to your routing dictionary 只需将新路由添加到您的路由字典

routes.MapRoute(
    "UserPage",                                              
    "{controller}/{action}/{user}",                           
    new { controller = "Home", action = "Index", user = "" }  
); 

You can read more about routing here at ASP.NET 您可以在ASP.NET上阅读有关路由的更多信息

NOTE: as Alexei Levenkov said it requires .Net MVC to route it that way. 注意:正如Alexei Levenkov所说,它需要.Net MVC来进行路由。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM