Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8494943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:26:06+00:00 2026-06-10T23:26:06+00:00

I have a .net github project that is basically a wrapper around a web

  • 0

I have a .net github project that is basically a wrapper around a web API. In the test project, I am calling to the API using an API key. I need to keep this key private, how do I accomplish this in a visual studio project?

In some other projects, like python, I can have git ignore the file (config.py) and use something like config.example.py. But in visual studio’s case, the project will not compile because of the missing file Config.cs. What is the proper way to solve this? I’m thinking of using this same method of ignoring the file and have them execute a build script that should rename Config.example.cs to Config.cs?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:26:07+00:00Added an answer on June 10, 2026 at 11:26 pm

    This is the perfect for .config files. Depending on whether its a web or console application, you will have a web.config or app.config file in your project.

    You can use the appSettings section to store your API key.

    To make things even easier, you can actually have this section read from another file, ie: specialappsettings.config and then just ignore that single file from your repository.

    Modify your web.config (or app.config):

    <configuration>
    <appSettings file="specialappsettings.config">
    </appSettings>
    <system.web>
    <!-- standard web settings go here -->
    </system.web>
    </configuration>
    

    Create a new specialappsettings.config file:

    <appSettings>
    <add key="APIKey" value="YourApiKeyValue" />
    <add key="AnotherKey" value="AnotherValue" />
    </appSettings>
    

    This can be accessed in your code via:

    var apiKey = ConfigurationManager.AppSettings["APIKey"];
    

    Notes:

    • You can keep your settings within the original web.config file as
      well but this lets you ignore just the specific settings file from
      your git repository without affecting the rest of the project’s
      necessary configuration details.
    • The same “key” can be saved in
      either file however the external file will override the original
      web.config file value.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using massive Massive Lib (github) for asp.net 4 project. I have
I have a private repository on GitHub that contains an ASP.Net MVC project and
I'm using Anything slider (https://github.com/ProLoser/AnythingSlider/wiki) and I have edited it so that the visitor
I have created a paging grid in asp.net with this jquery plugin(https://github.com/gbirke/jquery_pagination),that work fine.But
I have what I'd consider a standard .NET MVC3 Repository pattern project that I've
I have a ASP.NET MVC 4 project - CodeFirst with Entity Framework - that
I have two different .Net projects, hosted on github. I would like to create
I have .NET application that is hosted on IIS 6.1 It is impossible to
I have .Net service that listens on single port over TCP protocol. Clients connect
I have installed Mono 2.10.8 (that should have .NET 4 support) and MonoDevelop 2.8.6.4

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.