Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

191
Views
Convert in JavaScript C# code that reads from web.config

in the web.config file of my ASP.NET MVC application I have some constant string values. sommething like this:

<add key="filters" value="AA;BB;CC;DD" />

In a C# file I create a List in this way:

List<string> filters = new List<string>(ConfigurationManager.AppSettings["filter"].Split(new char[] { ';' }));

Now I have to put this code in a JavaScript file and create as many string variables as strings are present in this List.

For example, in this case I should obtain:

filterAA filterBB filterCC filterDD

How can I accomplish this task?

Thank you in advance.

Luis

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can add List to a view model in a controller, then you sent the data to View via ViewModel. Add this code inside of View

@model ViewModel

... your html code

<script>

   var filters = @Html.Raw(Json.Serialize(@Model.Filters));
 
 </script>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!