MVC 5, Create Dynamic Pages/Views From DataBase - asp.net-mvc

I'm currently working on building a simple website.
First time working with WEB technology.
I'm interested in building a website that is quite similar to 9Gag.com.
I can't manage to figure out how they create links and pages for each and every post that they have. I've been looking for a while but I can't seem to find the answer.
I would love if you guys could give me a hint or something.
Basically I just want to create dynamic pages for each post.
Thank you for your knowledge.

It looks like every item on that site has similar page layout and a URL in the form of /gag/[id]. That's about the simplest thing in the world to create. If you're struggling with that, you need to just spend some time going through the ASP.NET MVC tutorials. The only slightly complex part is that instead of some numeric id or a guid, they're using an alphanumeric id like you typically see in short URLs. That's purely stylistic though.

Related

MVC Base Controller implementation

We are now in the process of rebuilding some legacy WebForm apps using MVC 5. For one in particular the entire site is dynamic and built from returning a lot of markup from a back-end database, and that markup is different based on the domain name returned...
I got to the first stage of this one (the others not so difficult), building a dynamic menu and started scratching my head (and a few other body parts). In WebForms it was easy, MasterPage and code-behind, done and dusted...
After spending most of the day Googling I gather creating a Base Controller is the way to go... But there seems to be very little material showing how this can be achieved... What is out there is followed by a plethora of comments about how the author has got it all wrong and is direct violation of the MVC pattern...
Therefore, the question is, can someone provide a link to some documentation about how I can add a dynamic menu to a _Layout?
Thanks

Dynamically maintain standard maintenance pages for ASP.NET MVC 5 Application

New to ASP.NET MVC, but I have been looking around for quite some time and thinking how to achieve dynamically generate views based on the model? I have spent quite number of days reading articles online but I get confused at the end of day, so decided to ask a question, please help (if possible)..
I have about 25+ maintenance tables that requires CRUD functionality, so I wouldn't want to create + maintain 25 views and controllers.
It should be managed via a single controller and view based on the model supplied from Menu itself (as generics). How best to achieve this type of functionality?
Am pretty sure some of you have already implemented this type of functionality, it would be good if you share some insights?
Thanks in advance!
Yam

Adding content to umbraco?

I recently made the decision to develop our new company website (http://www.idealcode.net:8005/AboutUs.aspx) with Umbraco. I hired an Umbraco developer and we started work.
Please don't flame me or anything but I'm starting to worry about my decision.
The main reason why is because I seriously cannot find anything that explains in simple terms the workflow for creating a new page. As a web developer, it seems as much work to create a page in Umbraco than creating one outside of a CMS.
The workflow as we have it is:
Create a master page (probably not required for every page, but in practice seems to be on almost every page)
Create a document type with the PRECISE content areas that will be on the page
I guess at this point our end users can actually create a page...
We spent about 10 hours implementing the blog module and it STILL does not work and the dev needs to customize the template.
As a web developer, I honestly wonder how this is going to save us time? I'm not trying to diss Umbraco--I'm just worried about explaining this to my superiors. I could have created a site with some dynamic areas and blog in ASP.NET MVC in the roughly 20 hours we've spent on this so far...
The best way to get up to speed quickly on Umbraco is to look at the screencasts made from Umbraco corporate:
http://umbraco.tv/products/umbracotv
After that, the Umbraco community is quite good at answering questions and helping out:
http://our.umbraco.org/
As far as your specific question:
I could be wrong, but I think the thing that you aren't leveraging is inheritance. This makes things easier in Umbraco.
First, DocumentTypes can have parents and they inherit the data fields from those parents. For example, a Content Page DocumentType could have the meta information, main content area, and intro text.
Many pages within your site will likely go no further than that. Basically a rich text editor page (think "About Us")
Then when you add the News Item DocumentType, it can inherit all of those fields from Content Page and simply add a Date and Image field (as an example).
DocumentTypes can have many templates available to them. So if the data doesn't change, but the markup (design) does then you can set a new template in the Properties tab.
Templates can have parents as well. So you can build them up like this:
Main Template
|____One Column Layout
|____Generic Content Page
|____News Area
|____Two Column Layout
|____Product Compare
This works just like master pages in ASP.NET.
So this is pretty long winded. Maybe I'll think about a blog post. Does this help at all?
I second your thought, but consider following scenarios:
Umbraco or any CMS is no ideal solution, if:
1) The complete site will end up having only 20 pages
2) There is only a single user / editor of the site
3) The content is not much dynamic and once created will not change over couple of years
4) The site have only maximum 10 end users
5) The data is not pulled from any external source or/and all are static pages
Where as a CMS / Umbraco is solution for:
1) The is dynamic and still growing after first 1000 pages
2) The client have multiple editors and want to maintain history of publications
3) The content is pulled from various external sources
4) Site end users/contributors are 100+ and still growing
5) Last but not least, the site have 1000+++ visitors daily
I can go on and list all the possibilities of having CMS at the first place, but you need to decide and analyse your own requirements. There is no point in deploying a Samurai to kill a mouse, but definitely you should have proper equipment if you are going to hunt a tiger :D, joke apart just don't deploy any CMS for sake of learning.
Mean while, have a look in books available on Umbraco site to get started (http://umbraco.org/get-started/for-developers) or install Runaway module to start with.
Sanjay Zalke
>As a web developer, I honestly wonder how this is going to save us
time
It will save you time once you become proficient. It has a learning curve for sure, but once over that hump it will save you time - (that is not unique to Umbraco). I have used other CMS products that were easier to get my first site up - but then I was disappointed that I pretty much maxed out what the CMS could do for me - so far it doesn't appear that I will outgrow Umbraco's capabilities anytime soon.
Umbraco can be a wise choice if your site content is very dynamic with lots of pages.
The USP of Umbraco is the re-usability of the document types and a clear seperation of mark-up and content. It greatly reduces the headache of the site editor.
Although initially it may seem a bit confusing or i would say intimidating, but with the help of web-casts on http://umbraco.com/help-and-support/video-tutorials and the user forums things can get simpler.
I started using Umbraco a month back and so far experience has been good.
Start thinking about your site in terms of what is in common from one page to another. If every page in your site needs its own master-page than something is wrong. A good site layout will include the flexibility you need from one page to the next, but still enforce consistency and a common design.
Once you have the common elements of all the similar types of pages, start defining document types for this various types of pages. For example, you might have Basic Page document type, a News Item document type. You can define the various other pages, like "HomePage" or "Section Home", etc. If you have a slideshow, you could create a document type for each "slideshow Slide", etc. Umbraco allows you to build out a very flexible content tree very quickly, and is one of its biggest advantages.
Even if I am the only developer on a site, I still prefer using Umbraco over building a non CMS site. Once the site architecture it determined, development becomes very fast.

Multiple URLs and single codebase with ASP.NET MVC

I'm pretty new to ASP.NET MVC and I just want ask of this scenario is possible and, if so, could anybody provide any resource links on how to implement it.
Say I have a site that can be accessed from www.mysite.com, can I also have the same site load up through www.mysite2com, www.mysite3.com and so on? effectively providing the ability to run multiple sites from a single code base?
The idea is to have the site content and style sheet change depending on site visited but keep the structure the same.
thank you very much for any help you can provide :)
Kris
Yes, this is possible
http://web.archive.org/web/20100119084358/http://just3ws.wordpress.com/2010/01/03/skinning-your-asp-net-mvc-application-based-on-your-sub-domain
This example uses subdomains of the same domain but nothing stops you from using the same logic and have different images/CSS/paths etc generated based on full HOST/domain name

How to communicate between the Views in the Silverlight 3.0 application?

I am building a Silverlight 3.0 app based on the Silverlight Navigation Application template. One road block I ran into is communicating between the Pages. For instance, I am in one Page, and I want to kick off another page and send it some data. I am at a loss as to how to do this.
Any ideas?
You have 2 options
Use Publish/Subscribe pattern, i havent used this before, but it is useful in certain cases, i dont think it would solve ur problem though.
Use Request parameters, basically when you navigate to the new view, call it like so
NavigationService.Navigate(new Uri("/HomePage.xaml?HomePageId=12", UriKind.Relative));
You could slap some string.format in there to make it neater, but you get the idea, then on the new View, use string queryParam = HtmlPage.Document.QueryString["HomePageId"]; on page load to get the Id of the information you wish to display.
That should do it.
I've found an effective solution that does not involve too much complexity. I am using the LocalMessageSender and LocalMessageReceiver objects. The original purpose of these objects are to have 2 silverlight apps on the same web page talk to each, but it's just as good at having 2 views talk to each other.
The usage is really straight-forward. See this example for usage.
Jesse Liberty has an excellent blog post about just this. I use the techniques described there myself in a multi page Silverlight application.
I'm not sure though whether you can apply this with the Silverlight Navigation Application template.

Resources