This has been frustrating me for the past hour. My project is like
MySolution
MyTestProject
ClassThatTestsMyRepository.cs
MyMVCProject
App_Data
App_Start
Controllers
.
.
and the root of my problem is that my tests in the other project aren't working because they're trying to access a connection string that is in the MVC project itself. My plan was to add an app.config file and then reference the web.config in the MVC project. However, when I go to Add -> New Item there are no configuration files in Installed or Online.
The only reason there's a web config in my MVC project is because it was built from a template that added it. Any ideas how I can add it to my test project if I can't add it through stupid VS Web 2013?
It is just an XML file called "web.config" placed at the root of your MVC project. Then you can just create a new text file and rename it. if the project is a console app or a test project, the name is App.config.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="Default" connectionString="xxxx" />
</connectionStrings>
</configuration>
Add New Item...
Application Configuration File
for local apps or it will be under Web Configuration File
for ASP.NET projects.Add
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.