Multiple Web.config files in Area using ASP.NET MVC2 - asp.net-mvc-2

I have a question on something that I thought would be a simple. I have an Area in my website and I'd like to create a Web.config file specific to this area but, no matter where I put this config file, the keys that I've set up in my appSettings are all returning "null" when I access them, so I'm not sure what I'm supposed to do. Here's my website structure:
Site
[usual site stuff like Views, Models, Controllers]
Web.config
Areas
MyArea
Web.config
[usual site stuff like Views, Models, Controllers]
my web.config on the main site looks something like...
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="MyMainKey" value="MyTestValue"/>
</appSettings>
<!--all of the standard asp.net mvc config stuff -->
</configuration>
My areas config looks something like
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="MyAreaConfigValue" value="MyAreaTestValue"/>
</appSettings>
<!--all of the standard asp.net mvc config stuff -->
</configuration>
In a controller action that exists in my Areas/MyArea/Controllers folder I'm trying to access it like so:
string my_area_config_val = System.Configuration.ConfigurationManager.AppSettings["MyAreaTestValue"];
But my_area_config_val is null.
In a controller action in my main site (not in my Area) I can do
string my_main_config_val = System.Configuration.ConfigurationManager.AppSettings["MyTestValue"];
and my_main_config_val is equal to "MyTestVal", as expected.
Thanks.
Mustafa

The Web.config file goes in the Area/Views dir. I have not found any concrete facts, but from what I have seen in doing some research is that the <appSettings> from Web.config files within Areas will never get used. Below is one site that has a brief statement on it:
AREAS in ASP.NET MVC 2.0

Related

Adsense Bot looks for files for Adsense Matched content feature

Since i have implemented Matched content feature the Adsense bot (Mediapartners-Google) is looking for this tree files:
/google_matched_content_blacklist.txt
/google_matched_content_whitelist.txt
/google_matched_content_rules.xml
The file names sound like to control the Matched content feature,
but i can't find any description or documentation about this tree files.
Here is a sample of the /google_matched_content_rules.xml:
<rules>
<blacklist>
<uri>*.my-domain.com/exclude/*</uri>
</blacklist>
<whitelist>
<uri>*.my-domain.com/include/*</uri>
</whitelist>
<section>
<source>
<uri>*.my-domain.com/cat1/*</uri>
</source>
<target>
<uri>*.my-domain.com/cat2/*</uri>
</target>
</section>
</rules>
And the both files /google_matched_content_blacklist.txt and /google_matched_content_whitelist.txt are simple textfiles with a list of files or directories to exclude / include site in the related content.
! Keep Care: This is still not official documented !

Programmactly change in your web.config in releasemode

I have been roaming around the internet to figure out what the best solution to my issue would be, but I cant seem to find a satisfying answer.
My problem is, that I wish an administrator of my website to be able to change a server-setting (email, password and Exchange server endpoint url) - this should be possible to do in the browser, so the admin doesnt have to open up the web.config file.
The settings are rarely set, but the possibility for it HAS to be present.
What I do now, is that once the admin fills out my form, my controller will set the new values in the web.config AppSettings:
<appSettings>
<add key="ewsUser" value="some#thing.com" />
<add key="ewsPW" value="somePW" />
<add key="ewsUrl" value="https://outlook.ews.com/xxx.asmx" />
</appSettings>
This is where my big concern begins, because of all my research through out the internet.
Lets say my application now is online, and is being used by hundreds of people 24/7, would this solution then be an issue?
I have read that if you make changes to your web.config file it will make your application restart on the server, without throwing off any clients. But will this affect the session the clients are in right in that moment? Will the server forget their sessions?
I've read a bit on bad practices, and this article states how it could be solved by making a new .config file and link to that config file in the web.config AppSettings. But is this really necessary? I find it a bit more messy than my current solution.
Any ideas, thoughts and/or facts would be appriciated.
Writing to a web.config is indeed a bad practice. When changing a web.config file your application will restart. Not sure about the sessions though but they will probably reset. And what about the situation where you deploy a new version of your application and accidentally overwrite the web.config?
Two solutions that might be helpful:
Create a simple key/value table in a database
Create your custom XML format and write/read to a file (and name the file for example mysettings.config instead of mysettings.xml to prevent direct access from a webbrowser)
To speed-up things you could cache these values in memory after reading.

Why does my ClientLibrary css file keep including Bootstrap?

In CQ5, I've made a clientLibrary for one of my pages. Even when I remove all embed's and dependencies, the output .css file that gets loaded by my page has bootstrap at the top of the file. The client library itself just has a few js and css files that don't include or require bootstrap in any way. Am I missing something? Also I'm noticing the js file this clientLib outputs includes lot of scripts from my libraries that I'm not including in the clientLib or calling as a dependency/embed.
Below is my clientLibs .content.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root
xmlns:cq="http://www.day.com/jcr/cq/1.0"
xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:ClientLibraryFolder"
categories="[apps.myPage]" />
AEM saves the compiled clientlibs in a cache. Sometimes it happens the invalidation of the cache is not triggered. With using the following url you can execute the invalidation or the rebuild of your clientlibs:
/libs/granite/ui/content/dumplibs.rebuild.html
Is your problem not solved check the clientlib setup at the following page.
/libs/granite/ui/content/dumplibs.html
This page gives you insight about the embeds and dependencies on your clientlib. Probably a the reference still exists.
Everything configured well and it still doesnt work? In that case change the jcr:nodename of your clientlib folder. Check it once again.. Does it work, change back the name and it will work ;)

How to merge two prototypes in Pencil Wireframing Tool?

I am using Pencil wire framing tool. I have distributed the modules with my developers and now I want to merge all of them in a single solution. Instead of copy pasting page by page I think there can be a better way of doing this.
Also I wanted to know, is it possible of converting the one source file of prototype into another as I think collaboration feature in Pencil is missing.
Please assist.
Thank you
Open .ep files in your favorite editor. You will see an XML structure like
<?xml version="1.0"?>
<Document xmlns="http://www.evolus.vn/Namespace/Pencil">
<Properties/>
<Pages>
<page>...</page>
<page>...</page>
.....
.....
</Pages>
</Document>
Now just copy paste second .ep files all <page> at end of first .ep (Just before </pages>

Is it possible to redirect a link that ends with .aspx to a .ashx?

We have a website that we recently released based mostly on SharePoint. Some of the site needed to return just straight XML. The consultants on the project implemented the xml returns as .aspx pages that write the response object in the page_load method.
After a short time researching this, I relize that this is probably the wrong way to do this because it calls all the extra events for a ASPX page that we don't need.
Here's my question, I want to recreate these functions as .ashx links with the httphandler. However, I want to be able to retain the orginal links that ended in .aspx and the get parameters that accompany them to decide which type of XML to return.
Is is possible to rewrite/redirect the .aspx ending links to a .ashx link. Or would that cause the IIS server to interpret every .aspx incorrectly?
I think you're probably in luck...
We did a similar thing. Our eCommerce web app only accepts JPG, PNG and GIF files as the images for products, but we wanted every image to be dynamically created for every product.
So, we remapped JPG, PNG and GIF files to become a handler.
However, we didn't want ALL JPG, PNG and GIF files to be mapped since it would be hugely inefficient for static files, so we only did certain ones.
Here is how to do it.
If all of your ASPX files follow a similar file-spec that NO other files share, add this to your web.config under <httpHandlers>.
<add path="filespec*.aspx" verb="*" type="MyAssembly.MyHandlerName, MyAssembly"/>
If they don't all share a file-spec, you'll have to add them one-by-one to web.config:
<add path="oldaspx1.aspx" verb="*" type="MyAssembly.MyHandlerName, MyAssembly"/>
<add path="oldaspx2*.aspx" verb="*" type="MyAssembly.MyHandlerName, MyAssembly"/>
<add path="oldaspx3*.aspx" verb="*" type="MyAssembly.MyHandlerName, MyAssembly"/>
To make this usuable whether or not you are running in the IIS7 integrated pipeline, you could also add similar lines to the <handlers> element
Then when a request comes in for 'oldaspx1.aspx', it will get handled (very efficiently, without the page lifecycle being started) by your custom handler.
If this solves your problem, please mark it as the accepted answer with the check mark to the left.