ASP.NET MVC AdminPanel and Front Section File Structure - asp.net

I am working on this ASP.NET MVC Project to which i am very new.
I did some worked somehow on normal ASP.NET Web Forms back in days but i am really a beginner in ASP.NET. I developing projects in php for quite time and did never got a chance to try out .NET.
Back To Question:
I want to have two Sections, One for Administrators and One for Front End Users.
I want both Front End Users and Administrator(BackEnd) Users To have Different Themes Different Controller and Different Models.
In Simple PHP i did made base Controller Named My_Controller which extends the main Controller.
And after that i created two more base controllers derived from this my_controllers namely
AdminController
FrontEndController
and moved this based controllers to core directory or library directory.
But How to achieve such a thing in ASP.NET MVC, I am using ASP.NET MVC 5 at the moment.
Currently i just created new project using MVC. and Here below is the Current File Structure for my Project
Also Please Also Share what will be a better approach that making the base controllers for Admin Controller and FrontEnd Controller.
Or having Multiple MVC Projects in a project of a solution. Like HMVC.
But most importantly what is the best approach and how to achieve this admin and frontend file Structure.

Possible Solution 1:
The Good idea might be to use Area Feature of Asp.NET MVC. Area generally used for the purpose of sepration of user base, like in your case Public user and admin user.
Well explained details of area's can be found on following documentation.
http://msdn.microsoft.com/en-us/library/ee671793%28VS.100%29.aspx
Regarding the different themes for Admin and user web app, you can simply use different Layouts. Put two layout inside the View > Shared folder. Then specify layout on each view as below.
For User Views
Layout = "~/Views/Shared/_UserLayout.cshtml";
For Admin Views
Layout = "~/Views/Shared/_AdminLayout.cshtml";
Possible Solution 2:
if your project is big enough to think it will be difficult to handle the Areas later in a single project, you can also split the User and Admin project.
But you should be aware of re-usability of the source code by placing such code (such as Models) in other projects and adding reference.
I hope this solves your problem.

Related

Django CMS - how views are created

Im new to Django CMS and setting up a new project.
Would like to understand how the workflow works? I'm able to succesfully create a page and render it correctly but confused on how the views are created.
If you want custom views then you need to create your own applications which can be hooked in to CMS really easily.
Take a look at the docs; http://docs.django-cms.org/en/release-3.3.x/how_to/apphooks.html
Also, you can see an example of an application which can be integrated into CMS here; https://github.com/nephila/djangocms-blog/tree/develop/djangocms_blog

Adding simple CMS functionality to an existing MVC application

ASP.NET 4.51, MVC 5
Have read Integrating a CMS into an established application-centric MVC website
We have a number of MVC applications that serve as public facing websites. The applications were built using MVC as that was the technology stack understood by the developers and primarily the content that was being delivered was based on business process data.
However more and more we are being asked to add "another page" to the websites which for all intents and purposes is a plain old static content page. This ultimately involves:
Adding a new route
Creating a view with the required HTML
We have various "home grown" solutions which now pull HTML from the database for these views. However this means we are writing custom back end data entry screens as well as 1 & 2 above.
So.... There must be a better way. Has anyone got any practical experience or suggestions on how to add simple CMS functionality that we can give to end users, plugged into our MVC application? We need to provide the following functionality to the end user:
Create new pages, edit pages using WYSIWYG
Add meta tags and canonical tags for SEO
Specify the url portion of the uri for SEO purposes
All insights appreciated.
Is it feasible to do the following:
Have a database table to house the content for these pages. e.g. title, summary, description, url, meta, image(s) etc...
In the front end have a template for these pages. The database data fills in the placeholders within this template.
Perhaps hold all the pages on a base URL like www.yoursite.com/page/dynamic-page-url-from-db
You can use the Remote attribute validation on the url field to make sure they are all unique in the database.
With this in mind, create a single Route to catch the requests and filter valid/invalid requests in the Page controller based on the URL provided with the db. If non-existent throw new HttpException(404, "Page Not Found"); and have an error handler pick that up and deliver your 404.
META could be set via ViewBag or a dedicated section that alters the _Layout file at the point of rendering the view.
TinyMCE is a decent WYSIWYG editor. You can even add dynamic image gallery functionality to it if you want to embed images within the main body of the pages.
I'm working on making a CMS currently used in a demanding production environment into a product. I've just (as of 20 Jan 2015) made a NuGet package which installs the CMS into an MVC project which should be possible to add to any existing MVC site without breaking it. CMS functionality can then be added where needed. Currently I'm looking to work with some users to help them get the CMS into production on their sites, however this may have changed by the time you read this. Look at http://www.lynicon.com for more information and to sign up to a Slack community where I can give you access to the NuGet package.

New symfony bundle, when

On my symfony app, the time has come to add mailer functionality. Im always aware that that some new functionality justifiably goes into its own bundle. right now i want to add some mailer functionality so a user can check off some options, then send the items to a friend.
thinking ahead, i might also use that functionality in another bundle in this same app, which is a different part of the website.
so im thinking, i might want to put an email controller in its own bundle, but i know the swiftmailer bundle is already doing this, which i will be using.
so in the end im thinking its probably only a few lines of code i will need, and that may be best placed on the controllers of the specific parts of the website i need the email functionality on.
now comes the main reason i thought of making it its own bundle, twig templates for the email body's. do i want these templates dangling around in my other bundles? i guess it would make sense.
any suggestions?
It looks a bit overkill to create a bundle just for a few lines of code.
For your twig template you can put the shared template part inside app/Resources/views, which is shared for all your application. And put domain specific templates in domain specific bundles.
http://symfony.com/doc/current/book/templating.html#template-naming-locations
Whatever your email logic code should be inside a service wrapping swift mailer, like that if you need to switch mailing strategy, for example sending mails using an HTTP API, you just need to change this service, not all your controllers.
If you have some code to share between your bundles, may should you have an {App|Main|Core|...}Bundle containing all your "Single" services, that can be moved later in their own bundle if needed.
Anyway their is many approach for your global question :
You could use a single bundle containing all your business logic and externalize / decouple your technical / generic stuff inside bundles that can be shared between your apps
You could have an opposite approach with one bundle for technical stuff and many bundles for your business logic, may could it be harder to keep it low coupled
Or a mix of both
In my point of view the first approach works nicely for simple applications while second and third can be more domain oriented for bigger apps. The most important is probably to be consistant.

How can one build dynamic sitemaps in ASP.Net?

How can one build dynamic sitemaps in ASP.Net?
Sql Sitemap Provider
Physical file sitemap provider
You can take a look at these for ideas or just reuse them.
Not sure about your exact context (Forms or MVC, etc), but here are a couple of resources you can take a look at. You have several options, and I don't yet have the rep to post multiple links, so I'll post the google search link I did and call out a few links I found that could work for you.
http://www.bing.com/search?q=ASP.NET+Dynamic+sitemap&form=QBRE&qs=n&sk=&sc=1-23
Scan your site folder structure (using LINQ) and auto-gen a sitemap - 3rd Link (Creating Dynamic ASP.NET SiteMap using LINQ)
Implementing your own SiteMapProvider (MDSN) - 6th link (Implementing ASP.NET Site-Map Providers)
Implement and override the StaticSiteMapProvider - 4th Link (Adding dynamic nodes to ASP.NET site maps at runtime by deriving from ...)
SiteMapProvider for MVC - mvcsitemap.codeplex.com
Simple implementation using RouteTable values (MVC) - 10th link (Dynamic sitemap in ASP.NET MVC - Stack Overflow)
I hope these help, or point you inthe right direction. Feel free to comment with more details if you're looking for something more specific.

ASP.NET webpages without names, like stackoverflow?

Mentioned stackoverflow only as an example, but if you look above the URL for ask is
http://stackoverflow.com/questions/ask
which means /ask is a subdirectory, but they also do this for the specific question pages. How do you code this in .NET?
Not a code question as much as a technique. I know this is great for SEO, but how do you create a site so that every "page" is its own directory? Dynamically.
Do you have a template or a hidden redirect???
How?? :)
It's termed URL rewriting:
Url Rewriting with ASP.NET
MSDN: URL Rewriting in ASP.NET
EDIT: As #Justice points out, StackOverflow uses Routing.
StackOverflow uses something called Routing, which comes with .NET 3.5 SP1. Routing is a popular feature of a number of MVC frameworks, such as ASP.NET MVC, Ruby on Rails, and a number of Python and PHP frameworks.
Stack Overflow was built using ASP.NET MVC which uses a technique called Routing, see:
What Was Stack Overflow Built With?
and Routing
Stack Overflow uses ASP.net MVC
MVC uses the URL + Query String to determine the content, so its not like a URL which points to a specific page, but more like a hierarchical path to the properties of some data to be displayed
E.G. https://stackoverflow.com/users/[Put User ID Here]/[Put User Name Here]
prompts the website to display a USER with an ID specified in the path ( in this case the user name is probably just for kicks ) as opposed to a specific page created just for that user.
I have seen this accomplished by simply creating a folder for every web page and then having each folder contain a Default.aspx document (Assuming Default.aspx is setup as a default document in IIS, which it is by default). Then you can navigate to any folder on the site without specifying the page (Default.aspx).
For the dynamic part, I have worked with CMS systems that do it this way and the Default.aspx page simply inherits from some master template and the CMS system utilizes the ASP.NET rendering enginge to dynamically complete the web page.
Using folders may be a little heavy with the site structure, but it is an easy way to eliminate the page names from the browser.
This is how I structure my website and avoid having to use page names... for example http://www.innovaapps.net/Blog simply brings up the default.aspx page without having to specify the page name.

Resources