是否可以使用C#asp.net替换浏览器的URL而无需离开或重新加载页面? [英] Is it possible to replace the browser's URL without leaving or reloading the page using C# asp.net?

查看:35
本文介绍了是否可以使用C#asp.net替换浏览器的URL而无需离开或重新加载页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使在页面加载和替换之前,我也想访问浏览器的URL.

I would like to access the url of the browser even before the page is loaded and replace it.

我只是不想让用户看到他/她登陆哪一页.

I just do not want the user to be able to watch on which page s/he is landing.

虽然可以访问Page_Init中的URL,但是我不知道如何操作.

I though of accessing the url in Page_Init, but I can't find out how.

有什么想法或更好的解决方案吗?

Any thoughts or better - solutions?

我不需要更改(或删除)URL中的服务器名称,只需更改文件夹/文件名.因此,如果原始页面位置的格式为: http://www.server.com/folder/file.aspx ,我想将其更改为 http://www.server.com/misc/GeneralPage.aspx http://www.server.com/

EDITED: I do not need to change (or remove) the server name in the URL, only the folder/file name. So, if the original page location is of the form: http://www.server.com/folder/file.aspx I would like to change it to http://www.server.com/misc/GeneralPage.aspx or http://www.server.com/

Response.Redirect将不起作用.我想停留在同一页面上,但要更改URL.

Response.Redirect will not do. I would like to stay at the same page, but to change the URL.

Server.Transfer是带有帮助程序预登陆文件的默认解决方案,但对我来说还不够好.我想留在同一页面上,但是要更改显示的URL.

Server.Transfer is the default solution with a helper pre landing file, but it is not good enough for me. I would like to stay in the same page, but to change the displayed URL.

解决方案:

这里有一个涉及HTML5和另一个解决方案方向的答案,我想尽快进行调查,但现在不再存在(消失了).如果是您的答案,请再写一次.这很重要.

在这里,我给了我最佳的选择,这是我的行动决定(目前为止,直到找到更好的解决方案为止),但我对此并不表示赞赏(我未将其标记为答案).这是一个经过测试的详细解决方案.

I gave here the best option found as my decision of action (for now, until I'll find a better solution), but I do not take credit for it (I do not mark it as an answer). It is a detailed tested solution.

推荐答案

由于浏览器的安全功能,这是不可能的.如果浏览器允许程序员显示的URL与用户实际使用的URL不同,那么将会有更多的人在不知不觉中将其敏感的银行信息移交给第三方.

This is not possible due to browser security features. If the browser allowed programmers to display different URLs than what the user was actually on, then there would be a lot more people unknowingly handing over their sensitive banking information to third parties.

该URL应该标识浏览器请求并由服务器返回的特定资源.

The URL is supposed to identify the specific resource that was requested by a browser and returned by the server.

话虽如此,但您可以在域管理"级别使用一些域屏蔽技巧.GoDaddy使用的一种技术是通过屏蔽来转发您的域,这实际上是将您的网站加载到iframe中,以便将原始URL保留在原始域中,并在iframe中提供新内容.

With that said, there are domain masking tricks you can use at the Domain Management level. One technique used by GoDaddy is to foward your domain with masking, this essentially loads your website in an iframe so that the original URL is preserved at the original domain with the new content served up in an iframe.

您也可以自己使用此技术.当您将内容返回到浏览器时,返回一个src属性指向新内容的iframe.

You could also use this technique yourself. When you return content to the browser, return an iframe with the src attribute pointing to the new content.

不过,就修改实际显示的URL而言,这是不可能的,而且我不确定您为什么真的要这样做.

Still, as far as modifying the actual URL displayed, this is not possible, and I'm not sure why you would really even want to do this.

这篇关于是否可以使用C#asp.net替换浏览器的URL而无需离开或重新加载页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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