简体   繁体   English

如何使用asp.net在浏览器中更改URL名称

[英]How to change URL name in browser using asp.net

我遇到的情况是有一个登录页面。成功登录后,我被重定向到http:\\ localhost \\ default.aspx。我希望登录后浏览器的网址应类似于www.abc.com,但打开的页面将是http:\\ localhost \\ default.aspx。我无法使用URL重写来执行此操作

Unfortunately, this is not possible for internet users - you can't 'fake' the URL that your user is looking at. 不幸的是,这对于Internet用户是不可能的-您无法“伪造”用户正在查看的URL。 Otherwise evil-doers could re-write 'www.istealyourmoney.com' as 'www.trustworthybank.com', etc. 否则,作恶者可以将“ www.istealyourmoney.com”改写为“ www.trustworthybank.com”等。

The only possible option I can think of is if your users are all on the same local area network. 我能想到的唯一可能的选择是,如果您的用户都在同一局域网中。 In that case, you can add an entry to your HOSTS file with www.abc.com aliased to 'localhost'. 在这种情况下,您可以将别名为“ localhost”的www.abc.com添加到HOSTS文件中。

As said by JBRWilkinson this is not generally possible, however if you want to do this just to help you build out a site while you work on it locally, add an entry to your HOSTS file (on Windows: C:\\Windows\\System32\\Drivers\\Etc\\Hosts ) that maps www.abc.com to 127.0.0.1. 正如JBRWilkinson所说,这通常是不可能的,但是,如果您想这样做只是为了帮助您在本地处理站点时构建站点,请在HOSTS文件中添加一个条目(在Windows: C:\\Windows\\System32\\Drivers\\Etc\\Hosts将www.abc.com映射到127.0.0.1的C:\\Windows\\System32\\Drivers\\Etc\\Hosts )。 You want to add a line that looks like this to the end of the file: 您想要在文件末尾添加如下所示的行:

127.0.0.1    www.abc.com

Then you can access your local development website with the URL www.abc.com. 然后,您可以使用URL www.abc.com访问本地开发网站。 Note that this will also block access to the live version of that website on your machine. 请注意,这还将阻止访问您计算机上该网站的实时版本。

can't we achieve using IIS url rewrite? 使用IIS网址重写无法实现吗? http://www.codinghorror.com/blog/archives/000797.html http://www.codinghorror.com/blog/archives/000797.html

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

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