I'm trying to switch my custom cms written in php into .net c#. I was thinking to use cms as a learning project. I'm going to use C#, NHibernate ORM layer, mssql, mvc3 and jquery.
I'm aware there are plenty of commercials or open source cms, but still I'm going to spend some of my free time trying to learn new technology working on project like this.
So, is there anyone out there who is willing to share some ideas on creating cms domain model, usefull link, ideas, etc.
Thanks
A really basic CMS consist of 3 elements:
one database table to hold your "pages". The table structure is "name" and "content"
a route to transform requests of type /cms/pagename to a fixed controller, the method called cms and pagename as a parameter
a embeddable html editor
Now, there are two ways your "page" can be invoked. It is either create mode or view/edit mode.
In "create" mode, the page is requested but it is not in the database yet (e.g. cms/announcement1). In this mode you create a view consisting of a html editor and upon submit, you persist the page to the database.
In "view" mode, the page is requested and is IS in the database. You perform any necessary rewriting (for example you rewrite internal links of the form [cms/pagename] to a fully routable http address) and render the content.
If the user is authorized to edit the page, you also show a "edit" button which then invokes the html editor with the page loaded and ready to be edited.
And that's it.
There are tons of additional elements (caching, different built-in page types, embedding images, youtubes, preformatted texts) etc. but all of them are optional and you can introduce new features when you have the core already implemented.
Once I wrote a simple CMS following the structure above, it was a part of a bigger solution and till now it's been sucesfully deployed several hundred times. An advantage of a custom CMS is that it can be really simple and easily maintanable.
Related
I've got an application written in ASP .NET Core 3.1 that uses Razor pages to display various content.
I have a kind of project details view, where the details of the project are shown like image, description, some fields but also a list of files of the project.
The files of the project I collect using the Graph API (using credentials stored in Configuration/Azure Key Vault) and currently I list them out in a flat list. I store the list of files in my model (in a list with a custom object, to include metadata for the file)
I would like to show the files with folders, so the user only sees the top level folders and files when he opens the page. When he clicks on a folder, the folder should "open" and the user should now see the contents of the this folder (with an option to navigate one level up again).
Honestly, I am not quite sure how to start. I don't want to reload the whole page when the user clicks on a folder and as far as I know there is nothing like an Update Panel in ASP .Net Core that lets me only update parts of a page.
I also programmed some other Reat.JS applications, I know I could create a very dynamic react app to display those files but I am not sure if there is a good way to integrate such a react component in my ASP .NET Core app and also I don't know how I would pass the credentials to this component.
Hope someone can point me in the right direction and give me some tips.
Yes, there is no Update Panel in ASP.NET core MVC, but that doesn't mean you cannot update individual parts of the page. You can use a View Component to render just the content of a folder. The following is a list of key things you need to do to implement it:
Add a MVC action to your controller that returns View Component.
Enclose the folder content in a container div of known id.
Attach JavaScript event listeners to subfolders
When the user clicks one subfolder the event listener uses the fetch API to call the MVC action.
The event listener sets innerHtml property of the container div to the HTML returned by the MVC action
Attach event listeners to subfolders of recent loaded content.
This approach doesn't require any JavaScript framework or library. It can be implemented with plain vanilla JavaScript.
Probably you will want to add fetch and promise polyfills.
Unfortunately, this question is fairly broad and is likely to result in it being closed. (I didn't vote to close it). The challenge with this question is that there are so many different ways to handle this sort of programming problem.
Using ajax is one very common way to handle this. Which then brings us to javascript libraries, and there are a bunch of choices. You mentioned react. That is one good choice. If react feels too heavy for you then give my answer here a read with regard to Vue. VueJs is extremely lightweight and can easily be used on a single page or on a group of pages. Vue may be a great solution for you.
The main thing to know is that there is no "right" answer to your question which is why unfortunately it's not a great fit for StackOverflow. Here we prefer questions that have definitive answers. And this one has none.
I'm creating a new website application in asp.net. The landing page needs to have a button (or something similar) which the user can click to create a new instance of a webpage. Similar to how a Facebook user can create a new group/event or a StackOverflow user create a new question.
My website needs to be able to create multiple "events" from the landing page which can then be accessed from the landing page, each event should be a template populated with user details on creation.
Can someone please tell me how people refer to this technique of creating many instances of a webpage (event) from one template?
With ASP.NET Core MVC (using this as an example as you have an ASP.NET tag and your description doesn't specify a technology), you can create a template using a .cshtml file. If you are not familiar with these types of files (which are used within the ASP.NET framework), then I suggest a read of it here:
https://www.w3schools.com/asp/razor_syntax.asp
Roughly, it's a file with HTML content where you can easily embed .NET types (such as types from your Model) and .NET logic using "Razor syntax", so that your HTML file is modified appropriately (e.g. with queried data specific to your user) before being sent back to the client. The reference above gives good examples, so I'm not going to waste space and repeat them here.
You can have certain .cshtml files as your "template" and embed appropriate model data using Razor syntax. You can then have a hyperlink tag (for example) reference the .cshtml file using the asp-action attribute. This will render the .cshtml file to the client whenever that tag is clicked on. ASP.NET uses types called Controllers to handle such requests (Controllers are types that inherit from the Controller type) appropriately, such as querying the correct database and providing your .cshtml file with the correct data before sending the result back to the client.
ASP.NET Core MVC modularizes the types of actions described above very well (M --> Model, V --> View, C --> Controller). Here is a good reference:
https://learn.microsoft.com/en-us/aspnet/core/mvc/overview?view=aspnetcore-2.2
For other technologies that you wish to use to achieve the same result, you will have to consult the appropriate references.
Stackoverflow is a place to get answer on specific problem with short answer. Your problem is general design and programming question, and requires understanding of basic programming aproaches.
For that you should grab a book and read about designing webapplications in .Net.
Here is the task I'm checking:
1) have a product database, which is managed by another application (it has no relation with sharepoint).
2) now, my boss want to have an application within the sharepoint portal to search this database, plus, audit the searches, i.e. who searched what at what time....
There is no problem if this is a regular asp.net application. But, what's the best way to do this in sharepoint?
My plan is to:
use team site template (or blank template), create a webpart. then have UI, and gridview to show the result.
is this the way to do? I try to find an example of using gridview in webpart, but cannot find it. Is there any limitation of using asp.net control in webpart? what about use ajax toolbox control in webpart? any example?
thanks
Roughly there are 2 approaches you could go for:
The webpart approach, just as your describe it. You can use an ASP.NET gridview with no problems in your webpart. As such, a webpart is nothing more (simplified...) than a user control with some dress up.
Go for BDC/BCS. This will allow you to consume the external database and show the information as be it 'native' SharePoint data. This has the added benefit that the content can be made searchable from within SharePoint. Using this approach you also do not have to create a UI to present the data, as SharePoint will present it using the out of the box view pages, etc.
The downside of the webpart approach (option 1) is that if you have multiple front end servers in your farm you need to handle the session in a way (e.g. by setting up sticky sessions on your loadbalancer, or by sharing your session somewhere centrally (in a db for instance)), as you don't want users to switch between servers in one session while they are using your webpart probably.
The downside of option 2 is that at first it might seem complex, but let that not scare you away :-)
http://msdn.microsoft.com/en-us/magazine/ee819133.aspx
You should code this as one or several web parts. You can use pretty much any asp.net controls in web parts. If you want to use any third party tools like DevExpress you must ensure that the binaries are strongly typed so that you will be able to register them in web.config, note that the registration can be done by the wsp deployment if correctly configured.
Web parts behave as any .net code except for the fact as I mentioned all references assemblies must be "safe".
I am currently optimizing my site for search engines. It is mainly a database driven site. I am using C# on the back end but database content is loaded via jQuery ajax and a web service. Therefore, my database content is not in html at the point that the bots will crawl it. My site is kind of like an online supermarket format in that there are thousands of items in my database, users can load a single one of these or more onto the web page at a time and the page does not change significantly once items are loaded.
My question is, how (if at all) can I get my database contents indexed? I was thinking of having an anchor that links to an aspx page (eg called mydatabase) which loads all of my database items as a big html list. Then, using jQuery, I would make the anchor invisible to users. The data would still be accessible to users but not by this link, it would be accessed by using the jQuery interface I have created.
The thing is, I don't really want users to see this big, messy list - would google results show this page eg www.mysite.com/mydatabase.aspx as a search result? Also would google see this as "keyword rich" spam page? I have done quite a lot of research but found nothing on this. only instructions for php. Please help I'm not sure what to do and need to know the best way to go about this.
It's a shame you haven't taken the progressive enhancement approach as it would mean you would have started with a standard HTML output that's crawlable, and then adding the layering behaviour (AJAX) on top for the user experience.
Providing a single file (e.g. mydatabase.aspx) that lists all of your products in a list format provides no real value for the reason you gave - it would just be a big useless list. No editorial content relevance for each link etc.
You're much better off taking another look at your information architecture and trying ensure that each product is accessibile by it's own unique URL, then classifying the products into groups (result pages), being careful to think about pagination.
You can still make this act like a single-page application using AJAX, but you'd want to look into HTML5's History API to achieve this in a search engine friendly way.
I am creating a new support center and "self-help" customer service module for an application. The CIO really likes the flow of eBay's "Contact Us" pages, that basically work like this:
First, you select a specific topic from a group of topics (e.g. Buying, Selling, Account on eBay)
You're then presented with what appears to be one of three variable types of information, based on the topic you picked (names are just what I'm calling them in some preliminary sketches):
"Descriptive": displays rich text with possible links to other parts of the application.
"Choice": Displays a list of additional topics
"Action": Lets the user look up an item and do some action (e.g. cancel)
From some experimentation, a choice can list to other choices, or to a descriptive block of text, or to an action section.
I'm turning up blanks as to the proper architecture for this. My platform of choice is ASP.NET (WebForms, sadly; we have no desire to touch MVC here) so the "Action" areas would have to be a user control that's dynamically loaded into a placeholder, but I'm more concerned with a possible database structure for this. I would need a way to know if each topic leads to one of the three types above and then on the page dynamically load either the content, list of links, or user control which makes things a bit trickier, nevermind the fact that a non-technical user will have to update and add the information from some kind of administrative panel.
Any suggestions for doing something like this? I'm not on a tight deadline, but I can't take too long or I'll be considered to be wasting time and not producing results.
If you can store the "tree of knowledge" in some way, like a custom XML file which would organize all options / possible actions, descriptions etc. Then you can "walk" it based on user's selections and display appropriate user control with content generated on the fly based on the contents of the XML node you're currently at.
Your "admin tool" would then need to update/modify the XML file, and your "public" CMS would render user controls inside an ASPX form.
One of the projects I worked on used this methodology for intranet's user menu - effectively a knowledge base of hyperlinks / actions split in to categories so they can be drilled-down to. Each element can contain links to other elements - so you have a spider-web like navigatable chain / workflow.
Just make sure each element has a unique ID (trivial to implement) and you can always get at it through xpath.
By having users modify a "working copy" and keeping backups of the live XML file when changes are published you also get versioning / roll-back which would be difficult to do in a DB.
If I personally was doing this I would just roll some MVC3 controllers that handle the work flow steps as needed. That seems to be out for you however.
With webforms, I would most likely consider handling this using Windows Workflow Foundation (the learning curve is moderately steep on this). Here's a pretty good example on using WF Flexible Web UI Workflow application through ASP.NET MVC & Windows Workflow Foundation. It's built on MVC however you could easily replace the return Views() with return UserControls.
Following a model like this would defacto give you the MVC pattern. The controller dictating flow matches very well for a workflow scenario.
Edit: Since this even seems out of the question, at this point you're best option is just writing a controller class that will manage the flow manually (probably a bunch of state / if checks) and then redirect users or return the appropriate user control.