-2

In my application I have various Views and Controllers.

So naturally when one navigate through pages the URL will change based on the Controller and the View;

E.g.

  • http://example.com/home/index
  • http://example.com/account/register
  • http://example.com/product/newproduct

But I would like to keep the Controller and View name in the address bar secret, in other words when one would navigate, the address bar always shows http://example.com

Does anyone know how to hide these routes? I'm an using ASP.NET MVC 4 C# application.

Basically just need the server to keep track of the pages.

ekad
  • 14,436
  • 26
  • 44
  • 46
Shane van Wyk
  • 1,870
  • 1
  • 26
  • 62
  • My quesiton is why. It was developed this way for a reason, and you have not given any reason why hiding them is required. – Erik Philips May 07 '15 at 21:50
  • I was thinking about hiding it and then the server taking care of it. It was an Idea which I was not sure would even be possible. Which this post has confirmed by the looks of things. I was thinking of it as another layer of security. I'm still quite new to MVC so hence the question which you obviously think of as a dumb question. – Shane van Wyk May 07 '15 at 22:30
  • 1
    No not a dumb question. Simply asking literally why. So it was to be a security matter. The only issue is anyone with [fiddler](http://www.telerik.com/fiddler) would be able to see what the request looks like. However, when using [SSL the url is encrypted](http://stackoverflow.com/questions/499591/are-https-urls-encrypted). But anyone connecting (the client) will still be able to see the full request using an of the available DEV tools in IE, FF, Chrome, etc.. – Erik Philips May 08 '15 at 00:18
  • Ah ok yehp then that is fair enough that it would be pointless wasting time thinking about obfuscating the Route if it can be exposed by the client's web browser. Thanx for the input. – Shane van Wyk May 08 '15 at 00:27
  • 1
    I think you should go for **Single-Page-Application**. – BabyDuck May 08 '15 at 05:10

1 Answers1

2

Unfortunately, I believe that this is not going to be an easy task to accomplish. The MVC routing engine needs certain information to deliver the request to the screen and that information is handled when you map the route. Furthermore, you can imagine the kind of trouble people could get into if the browser allowed sites to alter the address ad hoc. Take a look at this video. It's pretty good about detailing how the routing engine works Pluralsight

Joel Priddy
  • 481
  • 3
  • 13
  • Good video and I kind of understand how it works, I was just thinking of it as; no one can use the URL to navigate, then only use the UI controls to navigate through pages. Basically let the server handle the state of which page is being requested etc. E.G. `ActionLink` where you pass in a `Controller` and an `Action`. The controller then returns something as a page, but in the URL it basically hides what it returned. – Shane van Wyk May 07 '15 at 22:50
  • @MikeSmithDev yehp came to that realization after this answer lol – Shane van Wyk May 08 '15 at 02:31