ASP.NET - best method for website where user can create articles (like a blog) - asp.net

I'm an ASP.NET newbie, but not so new at programming in general.
I'm creating a commercial website, and I want to allow an admin to add new articles (an article consists of text, images and various properties such as category).
I am trying to decide the optimal Modus Operandi. This site is commercial, so SEO is a major consideration. This means that I want each url to be "unique". That is, if someone navigates to an article about raccoons, he should be redirected to www.mysite.com/articles/raccoons. This means - I can't have one page that loads the appropriate article dynamically a-la AJAX (gotta use deep-linking)
So how exactly do I do this? suppose the admin entered his text, uploaded the images and set the article properties. I create a new subfolder, save the images to the server (I understand that saving images to a DB is a big no-no), their addresses in a DB, and the content itself to the DB. But now what?
How do I go about creating the actual page?
Is there a function for creating a new aspx file? then what about its corresponding cs file? Or is it unwise to use aspx? Maybe plain html? but then how does it work with my site's master page? Or maybe just create another copy of a general aspx file which is populated with an article according to a parameter?
I would like to know what is the "smartest" approach before I dive in too deep.

You can Consider ASP.Net MVC for this. What you need is more like a Content Management System rather than a Blog, as you mentioned an administrator will add articles.
By Using ASP.Net MVC, you have a very clean implementation there, your urls will stay as you need it for SEO, You dont have to create aspx pages on the fly but the framework will let you deal with new urls from your class files.

Related

Convert query parameters to "pretty urls"

I have an Episerver site with a JobDetailsPageController with a Index method that takes a jobId parameter and creates a view with some details about that job. The urls looks something like this: https://hostname/<root-depending-on-site-tree>/jobs/?jobid=44.
What I would like is having urls on the form .../jobs/manager-position-telco-44, essentiallly creating a slug of the job title and appending the id. I have done this in the past using standard ASP.NET MVC Attribute Routing on a non-Episerver site, but EpiServer has a routing of its own that I don't know too well and can't figure out.
Also, adding non-query strings after the slash consistently sends me (no surprise) to a 404 page, so I would need to somehow customise this behaviour. I need to use EpiServers standard routing to end up at the right "parent", but ignore the latter part (the pretty bit).
Is it possible to create such urls on a normal page in page tree in EpiServer? I do understand it is possible to create static routes, but this node can be moved around like any other page so I cannot avoid EpiServer.
Please see this blog post. What you're looking for is partial routing.
#johan is right, partial routing is one way of doing this. Just wanted to add other possible solutions that might or might not match your needs.
Import data as content
Instead of serving content dynamically, you could consider importing your job ads from whatever source you have directly in content tree as separate pages below particular root page. That would give you a lot benefits - pages would be cached, it would support multiple languages, editors would see content directly in EPiServer CMS, data could be adjusted manually, etc.
This would be a good solution if your data does not change often and you need to provide a way for editor to create a new job ad manually as well.
Implement you own content provider
Another way to serve your dynamic data to EPiServer is to write your own custom content provider. You can find documentation here: http://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/7/Content-Providers/Content-Providers/
This solution requires more coding and is more complex, but it has some benefits as well. If one wanted, it would be possible to not just serve content from external data source, but also update that data by changing values directly in EPiServer UI.

Can Sitecore templates be used to store SQL Queries or JavaScript

We are building a Page with dynamic functionality using ASP.NET + Sitecore 7.0.
Is it practical and appropriate use Sitecore templates for:
SQL Stored Procedure Name to be invoked
JavaScript to be invoked
ColumnNames to be used etc (related to coding customization)
Or should these configuration properties remain inside the ASP.NET Project itself?
What is the primary purpose of Data Templates in Sitecore?
Are they for developer customization or customer-level customization?
The purpose of a data template in Sitecore is to define the set of fields for content items which inherit from that template. - Think of a data template as a class and the content items (pages) as instances of that class.
Templates are usually used to define the user-editable content of pages within a site, that being said you can have items to store information which is not managed by regular content editors. The question is where do you draw the line between things which should be put into Sitecore and things which should be a part of the solution. My advice is only put things in Sitecore if they need to be there. If you have to have the ability for editors or admins to configure those settings/properties.
I would say that putting SQL/ColumnNames is probably a bad idea unless you are building some sort of report builder interface in which case it may be essential?
Likewise with placing JavaScript into Sitecore; this can be OK in moderation (e.g. snippets of analytics code which content editors may want control over?). If you're placing whole libraries of JavaScript into Sitecore, you're probably doing it wrong.
One final point to note is findability/re-factorability of code: if you have code spread between Sitecore and your solution, it can make it very difficult to maintain as it is difficult to get a complete overview of code involved.

Import asp.net and html pages in Umbraco CMS

I am new to Umbraco CMS. I have an existing website which is developed in asp and asp.net.
Now I have requirement to convert this existing website to new website using Umbraco CMS.
The pages available in existing website are almost all static pages..
My question : Is there any way to import these static pages into my Umbraco website.
So that I can skip the manual content creation of these pages in Umbraco.
In short, it depends on how much you need to edit on the original pages and how many pages there are.
If the content is never going to be edited, then you can maybe create most as just normal masterpages (umbraco templates). You can then just add in Navigations and other CMS spec
Or another way of doing it would be to create 1 template and add a big text box to the DocType which you can then paste the HTML into. However this will mean you will end up with loads of HTML in the DB.
If you want to make it a 'true' Umbraco site and use as much of the CMS functionality as possible then there is no really easy way of converting HTML into an Umbraco site.
If the data was in a DB you could use CMSImport and map the old to the new DocType fields, but you would still probably have to do some HTMLTidy work on it before importing.
Depending on the amount of pages, the best and easiest way is usually to just copy and paste in my opinion because it allows you the chance to perform a content audit at the same time and clean up HTML where necessary.
I did this before.
Created a basic template / view with header and footer and main content area.
Then use Screaming Frog (or a similar tool) to crawl the site.
Use the output of the page crawl to make a comma delimited list of Urls
then use this to find each page.
For each page, create an Umbraco page with the name of the url, ie /something-page-name = 'Something Page Name' Use HTML Agility pack to navigate the HTML and pull out key elements such as Title, Description etc and locate the main content by navigating the DOM and literally take the InnerHTML of that section into the content field of the Umrbaco page and save and publish it.
Make sure you allow your content editor in Umbraco to edit all the html elements found in the source page. Ie you may have section or small tags which the editor may not recognise.

Importing into SiteFinity

I just finished installing SiteFinity 3.7 standard version on windows server 2008. Is there a way to entirely/partially import an already existing .NET project (ASP.NET) into SiteFinity with some minor changes in the code of course (may be by changinf a couple of xml files or something similar). I could only see an "export" under Administration->Tools section but no import. I am new to SiteFinity so a detailed help/guidance would be much appreciated.
Thanks.
I think you're on your own here. Sitefinity stores everything in a database so you'll have to programmatically convert the sitemap (read XML insert into database). Sitefinity does have an API that allows you to do this. You can for example create pages and add controls to that page.
Sitefinity uses MasterPages as templates so that's easy. You can also re-use any controls you have.
But, by the time you're done writing the conversion code, I think you'll find that you could have done it all by hand in less time. Unless this is a huge website you need to convert.
if you just need to import the pages you can add them as "external pages". this allows you to set permissions, page properties, and add it to you navigation/sitemap but of course doesn't let you edit the page inside of sitefinity. I did this with some sites that were developed seperately but needed to be in our sitemap.
You could also wrap the content and code into user controls, then add those to the page. We did this for an application that we built. the pages had to live inside of sitefinity, but the programming was already done, and needed to be in user controls. Once again you don't get to edit the content in sitefinity, but you get to keep your existing code.
Finally, if you used any kind of content management system, you can easily import stuff like news/events/etc via the various managers, it works something like:
var mgr = new ContentManager("News");
var content = new mgr.CreateItem("text/html");
content.SetMetaData("Title", importedItem.Title)
...
mgr.SaveContent(content);
this isn't EXACTLY the code but it's something similar; you can use the api documentation to learn more.
If it's plain text, then unfortunately yes, you'll have to manually copy this into sitefinity. It is a bit of work, I did this with our hundreds of pages, but in the end it's worth it to have the cms benefits.
hope this was helpful!

How to make a fully customizable hosted ASP.NET MVC application

This is related to my previous question regarding serving static html files but that doesn't seem to be a good solution,
I want to make a fully customizable ASP.NET MVC application as a hosted service. See allowing the user to customize the look/feel of their own page but it is still dynamic, meaning the data is hosted in the central database.
I looked at the "theme" or "skin" in ASP.NET but I don't think it is customizable enough. It seems only the developer can add new themes. I want to have something like the theme editor in WordPress so you can just change the look in anyway you want from a web-based interface.
I wonder how the theme files will be stored for the popular blogging platform? Are they stored in database or a file in filesystem? I prefer to store it in database, because if it is in filesystem it will have scalability problem. Each user will be tired to a particular web server and I have to determine how much disk space for each webserver.
I thought of doing something like the old MovableType, to generate static HTML when you add new post. This solution is problematic as well, because the flexibility depends on the complexity of the template engine.
Ideas? Suggestions?
Thanks!
"Fully customizable" is the most elusive of the white whales ;-)
I see your question is old, but none the less;
first I'd recommend defining some very clear,
and cohesive rules governing just what the "bottom-line" is,
or an inheritable template of sorts.
You get a pretty good impression of what might be useful during developing, I'd guess.
Next; just what and how is the customizing supposed to be presented and achieved?
The inherit ASP.NET custom custard, Web Parts, need quite some cajoling to behave in MVC views :
https://stackoverflow.com/questions/1106629/using-webparts-in-an-mvc-application
If you're leaning more towards customizable appearance (theme's n' skin's),
how about having a CSS file for each user, saves like a charm as VARCHAR(MAX), and can easily be inserted
in e.g. your Master Page's head.
The theme editor in WordPress simply allows you to edit Theme PHP files...
You can do it exactly like in wordpress but instead of editing PHP files your theme is composed of a set of aspx\ascx files without code-behinds...

Resources