在asp.net web项目c#中隐藏url? [英] hide url in asp.net web project c# ?

查看:507
本文介绍了在asp.net web项目c#中隐藏url?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨所有

i用c#代码创建我的asp.net web应用程序项目

现在我尝试让我的URL对用户可见

例如:

www.mydomain.com\myprofile.aspx

i需要为用户显示www.mydomain.com



我怎么能这样做

是否可以做类似的事情

我需要为我项目中的所有链接做到这一点

www.mydomain.com \order.aspx?p_id = 46







请任何想法:)

hi all
i create my asp.net web application project with c# code behind
now i try to make my URL visible to users
for example :
www.mydomain.com\myprofile.aspx
i need to display only www.mydomain.com
for users ?
how can i do that
is it possible to do something like that
and i need to do that for all links in my project
www.mydomain.com\order.aspx?p_id=46



please any idea :)

推荐答案

不,你不想隐藏URL;整个概念没有任何意义,因为所有HTTP请求都与某个URL 一起使用。您想要的是 URL重写 http://en.wikipedia.org/wiki/Rewrite_engine [ ^ ]。

< br $>
请参阅:

http:// msdn。 microsoft.com/en-us/library/ms972974.aspx [ ^ ],

http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module [ ^ ]。



此CodeProject文章也很有用:用ASP.NET重写URL的一个例子 [ ^ ]。



更一般地说,有两种不同的技术:URL 路由重写,更一般地说,使用 HTTP处理程序。在这里你可以找到解释和比较:

http://msdn.microsoft.com/en-us/library/cc668201%28v=vs.140%29.aspx [ ^ ],

http://msdn.microsoft.com/en-us/library/cc668201%28v=vs .140%29.aspx #aspnet_routing_versus_url_rewriting [ ^ ],

http://msdn.microsoft.com/en-us/library/ms972953.aspx [ ^ ]。



-SA
No, you don't want to "hide URL"; the whole notion would not make any sense, because all HTTP requests go with some URL. What you want is called URL rewriting: http://en.wikipedia.org/wiki/Rewrite_engine[^].

Please see:
http://msdn.microsoft.com/en-us/library/ms972974.aspx[^],
http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module[^].

This CodeProject article can also be useful: An Example of URL Rewriting With ASP.NET[^].

More generally, there are two different techniques: URL Routing and rewriting, and, even more generally, serving dynamic content using HTTP handlers. Here you can find the explanation and comparison:
http://msdn.microsoft.com/en-us/library/cc668201%28v=vs.140%29.aspx[^],
http://msdn.microsoft.com/en-us/library/cc668201%28v=vs.140%29.aspx#aspnet_routing_versus_url_rewriting[^],
http://msdn.microsoft.com/en-us/library/ms972953.aspx[^].

—SA


可能有多个选项,比如使用iframe,url重写,服务器传输,客户端代码...



我不喜欢我认为有任何简单的方法可以在全球范围内完成,并且适用于所有情况。



例如,如果用户在另一个窗口或标签中打开链接,iframe将中断,刷新将无法正确刷新。 Java脚本中依赖于Java脚本的解决方案可能会失败。



因此,部分工作可能会付出很多努力。因此,您将不得不研究可用的选项(使用Google查找某些或不使用的选项),然后查看它是否适用于您的应用程序和框架,您可以接受妥协...
The might be multiple options like using an iframe, url rewrite, server transfer, client side code...

I don't think that there any easy way to do it globally that properly works in all cases.

For example, iframe will break if the user open the link in another window or tab and refresh won't refresh correctly. Solutions that depends on Java script might fails in Java script is disabled.

Thus it might be a lot of effort to have something that works partially. Thus, you'll have to study available options (uses Google to find some or reason not to do it) and then see if it apply to your application and Framework and you can live with compromise...

这篇关于在asp.net web项目c#中隐藏url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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