Does Orchard support some form of config transforms? - asp.net

What is "the Orchard way" to define environment-specific configurations and/or configuration transforms? Is it possible to use regular Web.config transforms like in any other ASP.NET web app, or does Orchard have it's own engine for this?
(I've not been able to find any useful information on this topic in either the official docs or out in the wild.)

It's perfectly possible to store that information in web.config, as in any other ASP.NET application. In lots of cases it's the only way to go (eg. environment-specific IIS settings and so on).
You may also store custom settings in Orchard database, by writing your custom settings part and attaching it to "Site" content type. It's the preferred way to go if you have some data to store, that does not have to be kept inside web.config file (alternative to creating a custom config section).

Related

Need Alfresco Share API to allow access to custom aspect form configuration info

I have specified form configurations for my custom aspects in my amp's share-config-custom.xml file.
We are planning to use standalone UI not share interface, and I'd like to access the field-visibility & appearance information I setup for my aspects.
Since the xml file is in a share amp I'm looking for some kind of Share API to allow me to query for it.
Go read about the form service. Then look at the Share tier and repo tier web scripts that are leveraged as part of that. Your custom front-end can probably reuse those.

How do I add custom locations at runtime without modifying web.config

I have an xml file with custom routes that I'm creating routes from on Application_Start in Global.asax. Some of those routes require authentication, some don't. Currently I have "location" entries for all those routes in web.config to control authorization.
I wonder whether there is a way to configure locations on application start at the same time I configure routes, so that I don't need to have entries in web.config.
I'm using ASP.NET WebForms .NET 4.0
Try creating your own (or looking at the many open source) sitemap providers. Your sitemap provider can allow you to dynamically change the sitemap nodes based on whatever logic you want and can also allow you to specify roles/users allowed to access each node...
An SO question showing the basic concept is here and a slightly more involved answer is here
That way, you can read your XML to calculate the URLs of the routes, merge it with any existing sitemap definition as appropriate and still get all the ASP.Net security benefits (Security trimming on sitemap, Authorization for URLs, etc.)
This doesn't answer your question directly but I hope this is of some help.

Storing configuration settings in web.config or database

What it best location to store various configuration settings of a web site modules.
Creating class (that inherit ConfigurationSection) that map the settings in web.config file?
Or creating some DAL and BLL clases that work with database?
I've used a simple heuristic to categorize each configuration variable into one of four categories:
Compile time configuration (changes done together with code changes) - if possible then inside the code or assembly (as an embedded resource), otherwise in web.config
Server instance specific configuration (SQL connection strings, local file paths) - in web.config
Application (database) configuration (feature selection and other global application settings that change rarely, if ever) - in database but without an UI
Application configuration - in database, accessible through an admin UI
Storing the configuration settings in the Web.config will have the effect that if you modify the web.config file, your application will be restarted and the new settings will have immediate effect.
If you are running the application on multiple machines, you however will need to update each machine.
If you store the configuration settings in the database, you will need to either restart your web application manually or have a function (such as an admin page/site) to allow the application to re-read the settings.
To actually answer the question:
Basic information is going to have to be stored locally in web.config (connection strings etc.)
Beyond that other information could be stored in either location.
Having it in the database means that it's easier to write admin pages to control the information rather than editing the web.config file directly.
How often are things going to change? If set up is a one-off thing then having admin pages would be overkill, but if there's ongoing changes (adding new users, categories etc.) then they might be a good idea.
Also with data in the database you can perform remote administration on the system
So, without more information on your application I can't make a recommendation.
In most times, you have separate settings for each module on each page. Thus, you have to save them in database.
Build a configuration section. It is pretty straight forward and suits your needs.

Add a sitemap provider at runtime in asp.net (MVC framework)

I'm building a regionalized site each region has it own sitemap and own content.
The regions can be added at runtime.
Is there any way to add a sitemap provider at runtime?
I need multiple site map providers at once so that I can leverage the mvcsitemap without to many changes.
You can create your custom site map provider in order to take information from database or from another file than web.sitemap.
Example of database sitemap: http://msdn.microsoft.com/en-us/magazine/cc163657.aspx
There is an MVC sitemap provider available at: http://mvcsitemap.codeplex.com/
I'm using it for a project right now. It has caching functionality built into the code so your overhead shouldn't be too bad. Even in debug mode running the sitemap for every request takes < 100 ms so I wouldn't worry about performance.
Your performance concerns are a little yagni too. "Could be quite resource consuming". You don't know so your just prematurely optimizing.

Can we create an application with its own Web.config and Forms Authentication section inside another application using Forms Authentication?

I have an application that uses Forms Authentication to authenticate one type of user. There is a section in this application that needs to be authenticated for another type of user using a different table in the database. The problem happens if the second type of user's session times out, she is taken to the login page defined in the Forms Authentication section of the main Web.Config instead of the login page for the second type of user. I am looking for solutions to this problem. One idea is to create an application in IIS for the section and create a Web.Config for the folder and add another Forms Authentication section. In my experiments, it seems this doesn't work. Am I missing something obvious? Any insights?
IIRC, the authentication works per folder. So you should be able to do it if all of the pages that require the 2nd type of authentication live in a specific sub-folder with it's own config.
Not 100% sure on this, though, so if someone more knowledgeable can contradict me I'll just delete the response.
You may need to double check me on the syntax, but the top level web.config can have any number of tags.
<location>...</location>
Inside you can specify separate config parameters for whatever folder/file you want. Look here for a reference.
EDIT: Apoligies, I neglected to format the code properly
You cannot have an <authentication> section inside of a <location> tag, so you must have the subfolder set up as an IIS (and ASP.NET) application of it's own. So, you should be able to run the subsection on it's own.
I think 500.19 is the "can't read or parse web.config" error - does it have details? You may need to turn on remote errors (or check Event Viewer) to see them. If you're still having issues, post a snippet of web.config.
As an aside - I've never been a fan of nested apps, and would probably prefer having your normal Login.aspx page handle it either with as a MemberOf or perhaps redirecting to a SpecialUserLogin.aspx or something. Nested apps are a PITA to setup and test, IME (for instance - I don't think you can even get it working under Cassini - though you can do 2 separate projects for it, and combine when you deploy).
Yes you can. The Web.config files have a tree-like inheriting arhitecture with override capabilities. Meaning you can modify the settings inside a sub-folder by placing a web.config file there and specifying different configuration settings.
The way I understand this problem, you have two solutions and the first is to look at Roles and the whole Provider Model would be a great place to start. Otherwise, the best bet would be to separate the application into two parts, breaking out the second user type area and then including it back into the main project via a Virtual Directory. Just remember that Virtual Directories inherit their permissions from the parent directories web.config, so you will need to use the <Location>tags to remove authentication for the virtual directory and then within the virtual directories web.config define your new forms authentication. This works well if you need Windows Authentication (NTLM) under Forms Authentication.

Resources