1

There is a site on ASP.NET MVC 5. The site have top-level sections - department of finance, department of customers services, etc. There are some entities like News, Materials, Permanent Pages. Currently it uses very simple routing system like :

http://awesomesite.com/en/finance/news
http://awesomesite.com/ch/customer/news?id=213
http://awesomesite.com/ru/archieve/page?id=333

where top-level sections (customer, finance) referenced to controllers and methods respectively. I need to modify this logic : let's say that there will be some breaking news, important materials or permalink pages. In this case it should have an unique URL defined by moderator\admin (dynamic). Example:

http://awesomesite.com/en/iwillbeback - actually it links to ../customer/news?id=21
http://awesomesite.com/en/announcementfromboss => ../archieve/page?id=666
http://awesomesite.com/ru/ourawesomesoftware => ../materials?id=001

Here arise a question. How can it be implemented on ASP.NET MVC? If I got some non-pattern URL, then my system should understand, what controller\method\id it actually links to. And as this pages ,materials , news will be added by non-programmer manager via some simple CMS, they will do something like : add a file -> select a departament -> write URL.

How can I solve this problem? I have an idea to create a table in DB like:

controller   method   arguments  generatedUrl
-------------------------------------------------
finance      materials   id=211  annualreport2015

I found similar approach here. However, if this site will be used by more than 50 000 users in the same time, will the perfomance be the headache? As I see, each request will invoke some search in DB. What could you suggest?

Community
  • 1
  • 1
Lua Sheng
  • 83
  • 1
  • 1
  • 4
  • You could theoretically do something in your router config to load them from a database/file/whatever at start up time... But this is an awfully broad question, mostly because you're asking several questions, but especially since you haven't tried anything yourself. – Heretic Monkey Nov 30 '16 at 17:27
  • @MikeMcCaughan, yeah, my bad. Just it is currently working site with a lot of users, so I can't do some experiments. Thought that there are some standard approaches to solve this case. – Lua Sheng Nov 30 '16 at 17:30
  • it all depends on the order of your route bindings. if you declare the route bindings for the static data first (e.g., {language}/finance/news/, {language}/archive/page), and then a catch-all, the catch-all could grab the custom url value ({language}/{vanityUrl}), then you would have to access a database to find the actual redirect url. You can use `Server.Transfer()` to maintain the vanity url, or `Response.Redirect()` to make the user's browser redirect to the actual url. (this is a comment as it is extremely high level) ex: https://msdn.microsoft.com/en-us/library/y4k58xk7(v=vs.110).aspx – ps2goat Nov 30 '16 at 17:36

0 Answers0