ASP.NET 4 Hidden Identity Routing

I am learning .net and building a site that uses URL routing.

I work, though, trying to get data from the database, I need to pass an ID parameter, for example:

services / {identifier} / {category} / {subcategory}

briefcase / {ID} / {category} / {name}

Blog / {date} / {ID} / {name}

I saw websites that do the same, but they don't seem to pass an ID parameter, how do they achieve this?

if they wanted to receive information about a particular service in accordance with the link above, would you simply run an SQL query looking for a match for the name of a subcategory or for a blog post that you are looking for by name and date on the blog?

It seems to me that this is a little strange, and if you have people adding blog entries, etc., there is always a small opportunity for more than one match.

Thanks for any help,

J.

+3
source share
4 answers

You can always check the name of your blog URL before it is released. If it exists, just add "_1" or something else. In addition, they mainly include the date.

+2
source

In ASP.NET routing, identifiers are most often passed in a URL when you use the HttpGet protocol. This usually happens when you have a link:

<a href="tvShows/comedy/35">Watch The Big Bang Theory</a>

There is your identifier that you want to avoid.

HttpPost ( ).

<form id="whatToDo">
    <input type="hidden" id="Category' value="tvShows">
    <input type="hidden" id="Genre' value="comedy">
    <input type="hidden" id="ShowId' value="35">
    <p>
        <input type="submit" value="Watch The Big Bang Theory" />
    </p>
</form>

, , : , ShowId , URL-.

, , javaScript/jQuery .

+1

, , , - . , , , sql , .

0

Usually, you should maintain a title → id relationship ... therefore, every time a blog is saved, updated or deleted, the corresponding entry in the title_id table is saved, so a search can be performed using only one select query.

0
source

Source: https://habr.com/ru/post/1784991/


All Articles