I built a simple ASP.NET website which has a menu with all the page URLs linked to each menu item. when I click on a menu item the page URL appears in address bar like "http://mywebsite/xyz/webform1.aspx". I would like to hide this page url and instead show only URL of the website like "http://mywebsite" for all pages. Please let me know how this can be achieved. thanks in advance. if this is too complicated to achieve, then is it possible to show a fake url in place of actual url for each page? I don't开发者_Python百科 want to show the actual page name in the url.
The only way you could reasonable achieve this is using what's normally called "URL Cloaking" you do this by using a frameset or iframe to wrap your pages so that all actions occur inside the frame without altering the browser URL.
In an unreasonable way to achieve this, you would need to write a custom view engine (I would recommend using MVC if you're serious about this) where you use a persistent store like session since it is bound to the user to store the "url" of the page. In your view engine you would have it interogate the session to determine the location the user is at for what physical page should be rendered.
After this you would need to implement all of your own Redirect/RedirecToAction functionality since you would no longer be using true redirects but would have a variable like RedirectLocation inside the session.
To do this would be a rather monumentally large task and I would recommend not doing this. If you absolutely feel you need the single URL go with the cloaking approach. Or as @Slaks commented just don't do this at all.
I found the solution at this link using the technique called "URL Routing" which is new in ASP.NET 3.5 SP1. I use ASP.NET 3.5 and IIS6. my main purpose was to hide the actual page URL (I should have made this clear in my question), which can achieved by showing friendly URLs using this technique. this article helps. thanks to you all for your prompt replies and suggesting other ways to achieve this.
https://web.archive.org/web/20201205221404/https://www.4guysfromrolla.com/articles/051309-1.aspx
Put your website in an iframe, for example you have index.html on www.mysite.com, in that index.html you have an iframe that contains the actual website, that way whenever users navigate through pages on your site, they will always see "www.mysite.com"
Not sure why you would want to do this... but a simple way to do it this is
Create a link button with the OnclientClick event set to a Javascript function:
<asp:LinkButton ID="myButton" OnClientClick="go();" runat="server" Text ="Go somewhere"/>
Next add a javascript function to go where you want to redirect:
<script type="text/javascript">
function go() {
window.location = "http://www.google.com/";
}
</script>
It will hide the URL - you'll just see a javascript call in the browser and the page will go where you want it to! Of course this is more work... but it works...
What you look for is usually called "single-page web application" or "one-page web application" (or even Single-Page Interface Model). It can be achieved by heavy use of JavaScript: user always stays on the same URI and all updates to the page are partial and fetched with XHR.
Try using Server.Transfer, Create a single page that acts as a gateway and passes the URL through. It should be pretty easy to implement.
you can use URL Rewriting for hiding address in url by web.config and Global.asmx file in Application_BeginRequest event and get url and rewrite this by HttpApplication app = sender as HttpApplication
app.Context.RewritePath(Path, true);
go()
doesn't camouflage, it sends you to that direction.
精彩评论