I just can not understand why # or ## in the MVC project. I press the button and get the url of the form http://localhost:55555/example/exm/List##

  • the first # is the beginning of the hash, the second is the content - Grundy

3 answers 3

A link like http://localhost:55555/example/exm/List## consists of two parts:

  1. Address where the transition should be made. If it matches the current page, no conversion is performed.

    In this case, it is http://localhost:55555/example/exm/List .

  2. Anchor , tagged place on the page where the rollback is made after the transition.

    The anchor is everything after the first lattice character; in this case, it is the second # character. This means that a rollback to <a name="#"></a> , or <div id="#">...</div> should occur.

If when clicking on a link, a pop-up window appears with a form, then clicking on this link is intercepted by the JavaScript onclick event handler. Then the address of the link does not matter; it works only when javascript is turned off and must be leading to a spare form on a separate page.

  • it works only when javascript is turned off and must be leading to a spare form on a separate page. - how can he lead to the spare form on a separate page if the address changes only # ? - Grundy
  • @Grundy means one of two things: either it is rolled back to a form on the same page, and the form itself is initially visible, but is hidden by the script; or the script itself extracts the anchor and makes certain actions based on its value. Regarding the second, I can say for sure: this is not MVC routing . - ߊߚߤߘ
  • @Grundy, если адрес меняется только # - this is on condition that the author had the link like href="##" , which he did not say directly. - ߊߚߤߘ
  • one
    @Grundy Pseudo-class :target allows you to make tabs or dialogues in pure HTML + CSS without scripts :) - Pavel Mayorov
  • one
    @PavelMayorov, so the discussion above was about the script, plus the spare form on a separate page . - Grundy

If interested, here’s a summary of the Universal Resource Identifier (URL (Uniform Resource Locators)).

 /* https://ru.wikipedia.org/wiki/URI RFC 3986 URI = [ схема ":" ] иерархическая-часть [ "?" запрос ] [ "#" фрагмент ] ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))? 12 3 4 5 6 7 8 9 // ? Ноль или одно // * Ноль или более // + Одно или более группа 2 — схема, группа 4 — источник, группа 5 — путь, группа 7 — запрос, группа 9 — фрагмент. URL: <схема>://<логин>:<пароль>@<хост>:<порт>/<URL‐путь>?<параметры>#<якорь> https://en.wikipedia.org/wiki/Uniform_Resource_Identifier - - A generic URI is of the form: [scheme:][//[user:password@]host[:port]][/]path[?query][#fragment] The following figure displays two example URIs and their component parts. hierarchical part ┌───────────────────┴─────────────────────┐ authority path ┌───────────────┴───────────────┐┌───┴────┐ abc://username:password@example.com:123/path/data?key=value#fragid1 └┬┘ └───────┬───────┘ └────┬────┘ └┬┘ └───┬───┘ └──┬──┘ scheme user information host port query fragment urn:example:mammal:monotreme:echidna └┬┘ └──────────────┬───────────────┘ scheme path */ 

As follows from it, the # you are interested in is the content of the part of the URI called a fragment (or an anchor in the terminology of the URL).

In practice, URLs and URIs are often interchangeable terms. Although the difference between them is (quote from here )

The term "uniform information resource index" (URL) refers to a subset of URIs that, in addition to identifying a resource, indicate how it is found by describing the basic mechanisms for accessing it (that is, its "position" in the network).

How exactly the fragment is interpreted depends on the performer URI / URL. In principle, it can be considered as another unstructured argument (the remaining arguments are passed in the part of the URI called the request )

    Usually, when developing in links, stubbing is done (in href, set the value to #)

    • This is clearly not a stub - the edit form appears - e1s
    • Well, I have often seen links that link to the same page with # at the end, while the action itself is clicked through JavaScript when pressed. In particular, the "add comment" link below works exactly like this. - Alekcvp