Access Application Folder - asp.net-mvc-3

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

Related

Where do you specify urls in a spring mvc project?

If we are calling an internal service we would look up its address from a service registry. But what if the service we are calling is external like some google api. What is the right place to declare the url? In the .net world we would define it in web.config but not sure what would be a good place to declare it in spring mvc.
If you are using Spring Framework
Good place to define all your static URLs would be in *.properties file.
Default one is application.properties
This file will be added in src/main/resources folder of project

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.

Register Jar from the lib-Folder as an Application in Spring Data Flow

I'm trying to create a self-contained application with Spring Data Flow (Mesos). To do that i want to register sinks/processors/sources that are maven-dependencies of my project.
I know that spring-data-flow accepts classpath:// as a scheme for references but it appears to be unable to find any jar located in the resource folder or (optimaly) the lib folder.
java.io.FileNotFoundException: class path resource [lib/spring-cloud-starter-stream-source-ftp-1.0.0.M1.jar] cannot be opened because it does not exist
How can i reference files from within my self-contained jar properly?
I'm trying to create a self-contained application with Spring Data Flow (Mesos)
What are the reasons behind "self-contained" solution? Why not register the apps from our repository directly?
There's already a way to register the OOTB applications using the "bitly" links that we provide. Please review the stream registration section from the reference guide.
More importantly, the latest release of SCDF's Mesos-server does not support maven artifacts. You'd have to use docker images instead. The docs linked above includes the "bitly" link for docker apps, too.

Setting up home page in spring

I am new to spring environment. I have created small test spring project through STS.
Project name: SPTest
base package name: uk.co.ifTest
When I run and open this project browser through Eclipse. It work fine, but url, it put in the browser is xx.xx.xx.xx:8080/ifTest/, instead of //xx.xx.xx.xx:8080/SPTest/.
I guess, it is adding base package name.
Is there any way I can open project with http://xx.xx.xx.xx:8080/SPTest/.
Thanks
ish
You need to change your context path for the server to point from ifTest to SPTest.
This answer will help you identify how to do it:
Changing Tomcat context path of web project in Eclipse

silverlight project setup

i have a a new silverlight solution in visual studio. i have created a silverlight class library to share common functionality. this class library has a service reference and so it has a ServiceReferences.ClientConfig file. the problem is if i create a project in this solution and add a reference to the class library it seems that i need a ServiceReferences.ClientConfig in this individual project. if i copy and paste the ServiceReferences.ClientConfig file from the class library to the project, everything works fine. if i do not i get the error below. doesnt this defeat the purpose of sharing this service reference in a class library? i want to be able to change where the service reference points to (debug machine / production machine) easily in one place. what can i do? is there another way i'm missing? Thank you.
Cannot find 'ServiceReferences.ClientConfig' in the .xap application package. This file is used to configure client proxies for web services, and allows the application to locate the services it needs. Either include this file in the application package, or modify your code to use a client proxy constructor that specifies the service address and binding explicitly. Please see inner exception for details. >
The config for the class library is not packaged into the .xap file. Without that configuration, the service reference cannot be properly configured.
doesnt this defeat the purpose of sharing this service reference in a class library?
Not really. The bulk of the "service reference" is the code in the class library. This is what you are sharing. Since a xap (or exe and web app) has only one config file, you must have the ServiceReferences.ClientConfig in the application's config file.
I am not aware of a mechanism to copy some important bits from the config file of a class library to the application config file during a build.

Resources