Does inheritInChildApplications Web.config attribute work in ASP.NET MVC 3? - asp.net-mvc-3

We have an MVC3 application deployed on IIS 7.5, and now need to deploy another app in a subdirectory of the main one. After running into Web.config inheritance conflict we tried to wrap the system.web section of the parent app's config file in <location path="." inheritInChildApplications="false">, as recommended in the accepted answer to web.config - how to prevent all inheritance, but we're getting an error:
InheritInChildApplications cannot be set to "false" if the location
path is referring to machine.config or the root web.config.
What are we doing wrong?

There was a known bug in 51Degrees.mobi component which accessed its config in a way that caused the application to crash when inheritInChildApplications property was used in the config file.
Apparently it has been fixed in newer library version as described here.

Related

Set Parent_Last on websphere 9

While using Websphere 7, I had in my EAR a nice little file called deployment.xml which told my WAS server to configure the deployment to PARENT_LAST. I had this file at
/MyEAR/META-INF/ibmconfig/cells/defaultCell/applications/defaultApp/deployments/defaultApp/deployment.xml
When moving to Websphere 9, it appears it is no longer honoring this directive. I go to the admin console and can see it thinks the EAR is deployed with PARENT_FIRST under "Class loading and update detection"
here is the text of the xml
<?xml version="1.0" encoding="UTF-8"?>
<appdeployment:Deployment xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:appdeployment="http://www.ibm.com/websphere/appserver/schemas/5.0/appdeployment.xmi">
<deployedObject startingWeight="10" warClassLoaderPolicy="SINGLE" xmi:type="appdeployment:ApplicationDeployment">
<modules startingWeight="10000" uri="Provider_lfcPractice_ImplWeb.war" classloaderMode="PARENT_LAST" xmi:type="appdeployment:WebModuleDeployment"/>
<classloader mode="PARENT_LAST"/>
</deployedObject>
</appdeployment:Deployment>
Is there still a way to configure the EAR to deploy the war with PARENT_LAST in websphere 9?
This should still work. Check this Select installation options settings, it talks about the deployment.xml
Process embedded configuration
Specifies whether the embedded configuration should be processed. An
embedded configuration consists of files such as resource.xml,
variables.xml, and deployment.xml.
So make sure that that checkbox is selected, as it is off by default. Also if you are deploying via wsadmin script, make sure that you are using that option.
The other way, would be to select all the options after installation that you require, export that ear and compare it to the one that you are installing.
With Gas's comment it was clear it should work. What happened to me is that I had added maven nature to the EAR at one point. Bad idea. Even though I had already removed the maven nature, it corrupted the file
org.eclipse.wst.common.component
It was missing the line
<wb-resource deploy-path="/" source-path="/"/>
When I added that line back, my deployment.xml file began working as expected

How to unit test classes within a WCF web service

How can I get a unit test project in a (VS2015) solution for a WCF web service to use the same web.config file for its own app.config? I don't want to have to replicate all the settings that are in web.config in my app.config (and have to remember to keep them in sync). Thanks.
I was able to shift the relevant settings to a separate config file using this method. One thing to remember is that paths are relative to the WhateverTests\bin\Debug folder when referring to the other config file in the Whatever project.

Startup.cs not needed on DEV machine but needed for deployment

I am developing an ASP.NET Web API v2 application. My application works fine from my DEV machine but when I go to deploy it to my server it gives the following errors.
The following errors occurred while attempting to load the app.
- No assembly found containing an OwinStartupAttribute.
- No assembly found containing a Startup or [AssemblyName].Startup class.
To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config.
To specify the OWIN startup Assembly, Class, or Method, add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config.
After searching Google, SO, and other sites I found adding a default Startup.cs class to my project fixed the issue. The problem is I don't know how.
What did adding Startup.cs do?
Why would my app compile and run on my development machine without Startup.cs?
This seems to involve OWIN but I was not even aware I was making use of any OWIN features.
This is most likely due to the way OWIN searches for its entry point (Startup class). In your dev environment you probably have a DLL in the project folder that has an OWIN Startup class. That dll is not being deployed as part of the deployment step and therefore doesn't exist in your deployed location.
Another posibility, along the same lines, is you're using .config transformations and you have defined a Startup class in your DEV config but not in your deployed config.
<appSettings>
<add key="owin:appStartup" value="StartupDemo.ProductionStartup" />
</appSettings>
OWIN Startup Class Detection might be informative.
MVC5 uses OWIN pipeline by default so it's "under the hood". Perhaps you migrated from a previous MVC site and that's why the Startup class was missing?
Cheers!

Maven Grails web.xml

Might be a stupid question, but in my current maven project i do not have a web.xml in my /web-app/WEB-INF folder.
There is no web-xml in my project and never has been, im trying to add it but my application is non-responsive to anything written in the web.xml. What am i missing?, iv tried specifying the path to it through the config.groovy like:
grails.project.web.xml="web-app/WEB-INF/web.xml"
Am i missing something? Do i need to specify the web.xml in some other config file in order to make my project utilize it ?
Run
grails install-templates
to copy templates that Grails uses for all code generation activities (including "web.xml").
"web.xml" file will be created in "src/templates/war" directory.
You may be able to get away with something similar to this https://stackoverflow.com/a/5891646/107847. It doesn't install separate web.xml but does allow you add what ever content you need or edit any of the generated content.

Access Application Folder

I am developing a webapplication using asp.net mvc 3.
In the solution I have a project for all the web/presentation things (models, views, controller) and in another project I have my services, daos and domainobject. now I created a config-file in my service-project with some settings. how can I access the file from my services?
If I don't set a path it uses the path of the asp.net exe.
Hope someone can help
Tobi
You can use AppDomain.CurrentDomain.BaseDirectory to get proper path.
Or change Build action property of your config file to Embedded Resource (msdn). After that you will be able to retrieve file using ResourceManager

Resources