0

I'm trying to hide the data from begin watched in the url, For example here is my route :

 routes.MapRoute(
         "Viewer",
         "viewer/{id}",
         new { controller = "Viewer", action = "Index" }
        );

and here is the controller method:

public ActionResult Index(int id)
        {}

as you see when i call the method it's gonna route and show the url like this :

 www.domain.com/viewer/1234

I want to remove the Id from begin watched and i want keep the method running as expected like this

www.domain.com/viewer

So how i can do that ?

ArunPratap
  • 4,816
  • 7
  • 25
  • 43
Dummies EBooks
  • 175
  • 3
  • 12
  • Since the URL passed with GET request, you cannot hide it because it's necessary to provide unique parameters in action name. Use URL rewriting, parameter encryption/hashing or SEO-friendly URL instead, depending on your choice. – Tetsuya Yamamoto Nov 29 '18 at 01:12
  • Well the page is noindex , so there is no effect .. if there is a way to do that even using ajax please let me know ... thanks – Dummies EBooks Nov 29 '18 at 01:18
  • How can that `id` parameter passed to the URL? Are you using `ActionLink` or something else inside the view to provide `id` parameter? If the URL coming from browser's address bar, certainly you need to use `id` parameter. – Tetsuya Yamamoto Nov 29 '18 at 03:35

1 Answers1

-1

As you, Since you want to pass data with GET request, you have to send id or everything else that you can search and find that data. I suggest you hash URL. To hashing URL: url hash

Makyen
  • 31,849
  • 12
  • 86
  • 121
Ali Dalir
  • 11
  • 4
  • Your profile indicates you may be associated with the links you've included here. Linking to something you're affiliated with (e.g. a product or website) without disclosing that affiliation *in your post* is considered spam on Stack Exchange/Stack Overflow. See: [**What signifies "Good" self promotion?**](//meta.stackexchange.com/q/182212), [some tips and advice about self-promotion](/help/promotion), [What is the exact definition of "spam" for Stack Overflow?](//meta.stackoverflow.com/q/260638), and [What makes something spam](//meta.stackexchange.com/a/58035). – Makyen Nov 29 '18 at 05:55
  • Further, just including a link to your site in your posts, without the site you are linking to being specifically relevant to *that post*, is considered spam on Stack Exchange. If you're including it as some type of signature, we don't do signatures in posts. Your user-card is displayed below the post. That's your signature. – Makyen Nov 29 '18 at 05:58